数据清单问题 [英] datalist problem

查看:103
本文介绍了数据清单问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个数据列表,其中包含三个复选框,其中包含
1.用户名
2.读取权限(可见性为假)
3.写入权限(可见性为假)
我将它们绑定到数据库.
现在我想的是,当被选中然后读取用户名复选框,并写复选框是可见的事实.

这是设计代码:


Hi all,

I have a datalist in which I took three check boxes contain
1. user name
2. read rights(visibilty false)
3. write rights(visibilty false)
I bind them to data base.
Now I want that when the username checkbox is checked then read and write checkboxes are visible true.

Here is the design code:


<td>
                                               <table id="complicated">
    <asp:DataList GridLines="Both" BorderStyle="Solid" ID="dList1" runat="server"

            OnItemDataBound="dList1_ItemDataBound"

            OnSelectedIndexChanged="dList1_SelectedIndexChanged" oneditcommand="dList1_EditCommand"

                                                       onitemcommand="dList1_ItemCommand" onitemcreated="dList1_ItemCreated" >
        <ItemTemplate>
        <table =" border-style:solid;" style="width: 484px">
        <tr>
            <td>
            <asp:Label ID="lblId" runat="server" Text='<%# Eval("id") %>' Visible="False"></asp:Label>
            </td>
            <td class="style14">
                <asp:CheckBox ID="cboxPermission1" runat="server"

                    text='<%# Eval("username") %>' AutoPostBack="True"

                    oncheckedchanged="cboxPermission1_CheckedChanged"  />
            </td>
            <td style="overflow:scroll;height:0px; width:100%;">
                <asp:CheckBox ID="cboxPermission2" runat="server" Text="Read"

                    Visible="False"  />
            </td>
            <td style="overflow:scroll;height:0px; width:100%;">
                <asp:CheckBox ID="cboxPermission3" runat="server" Text="Write"

                    Visible="False" />
            </td>
        </tr>
        </table>

        </ItemTemplate>
        </asp:DataList>
         </table></td>




我不了解如何在选中用户名复选框后将可见性设置为true.

请帮助




I did not understand how I can set visibility to true on checkchanged of username''s checkbox.

Please help

推荐答案

您可以通过使用jQuery或DataList.ItemCreated事件来执行此操作,如果您使用的是jquery,则遍历从DataList生成的表并获取值的用户名,并因此设置了读取权限和写入权限复选框的可见性,如果使用DataList.ItemCreated事件,则通过
获取用户名复选框的值 昏暗的用户名作为CheckBox = _
CType(e.Item.FindControl("cboxPermission1"),CheckBox)
在获取复选框通过使用其属性已检查"获得其值之后,并使用相同的语法对其值设置了读取权限和写入权限复选框的可见性,我希望这足够了
You can do this by either use of jQuery or DataList.ItemCreated event, if you use jquery then traverse table which is generated from DataList and get the value of username and accordingly that set visibility of read rights and write rights checkbox, if use DataList.ItemCreated event then get value of username checkbox by
Dim userName As CheckBox = _
CType(e.Item.FindControl("cboxPermission1"), CheckBox)
After get checkbox get it value by using it''s property "Checked" and accordingly it''s value set visibility of read rights and write rights checkbox visibility with same syntax, I hop this is enough


你好 阿伦,

更新后的答案是:
Hi Arun,

Updated Answer is:
document.getElementById(Read).style.display = visible ;
          document.getElementById(Write).style.display = visible ;




这是完整的解决方案:

写入.cs文件




This is complete solution:

write in .cs file

protected void dList1_ItemDataBound(object sender, DataListItemEventArgs e)
   {
       CheckBox chkPermission = (CheckBox)e.Item.FindControl("cboxPermission1");
       CheckBox chkRead = (CheckBox)e.Item.FindControl("cboxPermission2");
       CheckBox chkWrite = (CheckBox)e.Item.FindControl("cboxPermission3");
       chkPermission.Attributes.Add("onclick", "showhideReadWrite(this,'" + chkRead.ClientID + "','" + chkWrite.ClientID + "');");
   }


在< head></head>之间写入.aspx文件标签


write in .aspx file between <head></head> tag

<head>
<script language="javascript" type="text/javascript">
       function showhideReadWrite(_this, Read, Write) {
           var visible = (_this.checked) ? '' : 'none';
           document.getElementById(Read).style.display = visible ;
           document.getElementById(Write).style.display = visible ;
       }
   </script>
</head>




如有任何疑问,请让我知道.

请提供"投票":thumbsup:如果有帮助,请提供"接受答案",如果这是正确的答案.:rose:

谢谢,
Imdadhusen




Please do let me know, if you have any doubt.

Please provide "Vote":thumbsup: if this would be helpful, and make "Accept Answer" if this would be correct answer.:rose:

Thanks,
Imdadhusen


这篇关于数据清单问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆