chkTypeofIncident.DataSource = from t2 in
dbl.usp_GetIncidentsType().AsQueryable()
where t2.IncidentTypeFlag== '2' select t2;
chkTypeofIncident.DataTextField = "Incidents";
chkTypeofIncident.DataValueField = "IncidentsMasterID";
chkTypeofIncident.DataBind();
我使用LINQ獲取了選定的值。但輸出是總是檢查數據庫中的最後一個值。複選框列表需要根據DB中保存的值進行檢查
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();
}
什麼是你的問題? – Izzy
chkTypeofIncident是複選框列表的ID。假設查詢結果爲1,2和3意味着。我想檢查所有的值,但現在只檢查最後的值 –