Tuesday 1 June 2010

Değere göre CheckBox'ın seçili olmasını sağlamak

Veritabanında kayıtlı olan değerlere göre CheckBoxListte seçili olarak gelmesini sağlamak.

[C#]
CheckBoxList chkbx = (CheckBoxList)FormView1.FindControl("CheckBoxList1");
 
while (rdr.Read()){
 
ListItem currentCheckBox = chkbx.Items.FindByValue(rdr["ID"].ToString());
 
if (currentCheckBox != null){
currentCheckBox.Selected = true;
}
}

Referans: http://www.mikesdotnetting.com/Article/53/Saving-a-user%27s-CheckBoxList-selection-and-re-populating-the-CheckBoxList-from-saved-data