dhivya krishnamoorthy dhivya krishnamoorthy - 7 months ago 34
C# Question

Checkbox list need to be checked based on the values saved in DB

chkTypeofIncident.DataSource = from t2 in
where t2.IncidentTypeFlag== '2' select t2;

chkTypeofIncident.DataTextField = "Incidents";
chkTypeofIncident.DataValueField = "IncidentsMasterID";

I got the selected values using LINQ. but output was it always checked the last value in database.

var CheckedInc = from t2 in dbl.usp_GetIncidentsTypeDetail(Convert.ToInt32(HiddenIncidentRegisterID.Value)).AsQueryable()
select t2;
foreach(var chk in CheckedInc)
chkTypeofIncident.SelectedValue = chk.IncidentsMasterID.ToString();

foreach (var chk in CheckedInc)
chkTypeofIncident.Items.FindByValue(chk.IncidentsMasterID).Selected = true;