How to Retrieve checkbox list values from database to textboxes in c#
The value in database is saved with comma like abc,def,ghi..
and I want to retrieve value in checkboxlist
1.Check_abc
2.check_def
3.check_ghi.
The program is in windows application form
Thanks
Loading
Angel PrincessPosted Mar 18, 2014, 1:28 AM
Lakshmanan Sethu SankaranarayanPosted Mar 15, 2014, 7:37 AM
Angel PrincessPosted Mar 15, 2014, 6:57 AM
Angel PrincessPosted Mar 15, 2014, 6:57 AM
amrik singhPosted Mar 15, 2014, 2:43 AM
step1. split your db values and put in arry... use single quote..
step2. loop through the array and add values to the checkboxlist.
string[] newArry=dbvalue.split(',')
//list item need . text and value. right now both r same
checkboxlist.Items.Add(new ListItem(item, item.tostring()));
}
let me know if it did not help , i have full working code that i wont mind to share.
Girish SapariyaPosted Mar 14, 2014, 6:20 AM
Create your checkbox inside the loop.
like this:
for(int i = 0 , i < arr.Length; i++)
{
CheckBox chk = new CheckBox();
chk.Content = "Check_" + arr[i];
//set others propery if required
//add to UI control let say i have a stackpanel in UI with name spCombo
spCombo.Childrens.Add(chk);
}
Hope this will help you: :)
Angel PrincessPosted Mar 13, 2014, 2:26 AM
Girish SapariyaPosted Mar 13, 2014, 1:50 AM
do you want to show 3 check boxes on UI?