如何在.net中设置多个子复选框

时间:2018-09-13 16:50:07

标签: c# asp.net arrays loops checkbox

我有一个函数,实际上我想在一个父复选框中使用多个子复选框

  [] User Data
     [] create 
     [] delete
     [] update
  

但是使用我的代码我发现了类似的东西

  [] User Data
  [] create 
  [] delete
  [] update
  

一个接一个地添加,依此类推...

我有数据库,其设计类似于表。名称为“ groupFunction

functionName   functionId   button

 User Data         10        create
 User Data         10        delete
 User Data         10        update
  

我的代码是

private void CheckboxListBind()
        {
            //return 1 item since i Have one Item on DB 
            string selFunctionName = "select distinct functionName  from groupFunction where functionId ='10'"; 

            //dt is DataTable which is called in globally 
            dt = dp.getDataTable(selFunctionName, "groupFunction");
            int pCount = dt.Rows.Count;

            if (pCount > 0)
            {
                //FORM_createUser data
                string btnChildCount = "select button from groupFunction where functionId = '10'"; // it return  
                DataTable cdt = new DataTable();
                cdt = dp.getDataTable(btnChildCount, "groupFunction");

                int count = cdt.Rows.Count;
                if (count > 0)
                {
                    //FORM_createUser0
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        chkListForm.Items.Add(dt.Rows[i]["functionName"]);

                        for (int c = 0; c < cdt.Rows.Count; c++)
                        {
                            chkListForm.Items.Add(dt.Rows[i]["button"]);       
                        }
                    }
                    count--;
                }
                pCount--;
            }

        }

0 个答案:

没有答案