jeudi 13 septembre 2018

How to set multiple Child Checkbox in .net

I have a function which is actually i want to use multiple child checkbox in one parent checkBox For Example

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

But using my Code i have i have found something like

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

Adding One after another and so on...

I have Database which design is something like table Name is "groupFunction"

functionName   functionId   button

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

My Code is

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--;
            }

        }




Aucun commentaire:

Enregistrer un commentaire