Friday, February 5, 2010

Use OnItem Data Bound function

private void gdListOfQuestions_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
try
{
System.Web.UI.HtmlControls.HtmlInputCheckBox chkbx = new System.Web.UI.HtmlControls.HtmlInputCheckBox();

if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
string[] strSelectedQn;
strSelectedQn = selected_qn_ids1.Value.ToString().Split(',');
for (int i = 0; i < strSelectedQn.Length; i++)
{
if ((strSelectedQn[i].ToString() == e.Item.Cells[0].Text))
{
chkbx = ((System.Web.UI.HtmlControls.HtmlInputCheckBox)(e.Item.FindControl("chkAssign")));
chkbx.Checked = true;
}
}
}
}
catch (Exception ex)
{
String errorMessage;
errorMessage = "Error: ";
errorMessage = String.Concat(errorMessage, ex.Message);
errorMessage = String.Concat(errorMessage, " Line: ");
errorMessage = String.Concat(errorMessage, ex.Source);
LCE.Configuration.ErrorLog("Assessment/CreateAssessment.cs", errorMessage);
}
}

No comments:

Post a Comment