chkTypeofIncident.DataSource = from t2 in
dbl.usp_GetIncidentsType().AsQueryable()
where t2.IncidentTypeFlag== '2' select t2;
chkTypeofIncident.DataTextField = "Incidents";
chkTypeofIncident.DataValueField = "IncidentsMasterID";
chkTypeofIncident.DataBind();
我使用LINQ获得了选定的值。但是输出总是检查数据库中的最后一个值。
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();
}
答案 0 :(得分:1)
immediately available
答案 1 :(得分:0)
chkTypeofIncident.SelectedValue = CheckedInc.FirstOrDefault().IncidentsMasterID.ToString();
//here you also can use where condition