来自多个sql表列的问题Checkboxlist填充 [英] problem Checkboxlist population from multiple sql table column

查看:83
本文介绍了来自多个sql表列的问题Checkboxlist填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表Table1,其中有4个字段TView,TRead,TUpdate,TDelete整数类型.
这些字段存储1或o.


I Have one table Table1 which have 4 field TView,TRead,TUpdate,TDelete integer type.
these field store 1 or o .


<asp:CheckBoxList ID="chkEmplyeeMaster" runat="server"

                          RepeatDirection="Horizontal" CssClass="chkclass">
                      <asp:ListItem Value="1">View</asp:ListItem>
                      <asp:ListItem Value="2">Read</asp:ListItem>
                      <asp:ListItem Value="3">Update</asp:ListItem>
                      <asp:ListItem Value="4">Delete</asp:ListItem>
                      </asp:CheckBoxList>




当任何一个chekbox都被咀嚼时,则将其存储在Sql表中1.

现在我在以上"列中的所有值均为1,我需要编辑checkboxlist值.
我如何从这4个字段值填充chekboxlist,当值为1时检查,否则在0值处显示取消选中.

请帮助我......................................
感谢




when any chekbox cheked then its store 1 in Sql table.

Now I have these Above column all value is 1 i need to edit checkboxlist value .
how can i populate chekboxlist from these 4 field value ,when value is 1 then checked otherwise at 0 value its show uncheck.

please help me .......................
thanks

推荐答案

您好
尝试像这样更改复选框列表
Hi
Try to change the checkbox list like this
<asp:CheckBoxList ID="chkEmplyeeMaster" runat="server"

                          RepeatDirection="Horizontal" CssClass="chkclass">
                      <asp:ListItem Text="View"></asp:ListItem>
                      <asp:ListItem Text="Read"></asp:ListItem>
                      <asp:ListItem Text="Update"></asp:ListItem>
                      <asp:ListItem Text="Delete"></asp:ListItem>
                      </asp:CheckBoxList>



只需创建一个像这样的通用功能



Just create a common function like this

private void SetCheckBoxListSelection(CheckBoxList cbxlist,string OptionName, bool Value)
    {
        var item=cbxlist.Items.Cast<ListItem>().Where(li => li.Text.ToLower().Equals(OptionName.ToLower())).FirstOrDefault();
        if (item != null) item.Selected = Value;
    }



然后调用此函数
通过



Then call this function
by passing the

SetCheckBoxListSelection(chkEmplyeeMaster,"View",TView==1?true:false);


这篇关于来自多个sql表列的问题Checkboxlist填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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