protected void GridView3_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowState != DataControlRowState.Edit)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
foreach (ListItem c in CheckBoxList1.Items)
{
if (c.Text == userID.Text)
{
c.Enabled = false;
}
}
}
}
}
and to retain the checkboxes statuses whether checked or not
protected void GridView3_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
DataTable dt2 = ViewState["DatainEditMode"] as DataTable;
int index = Convert.ToInt32(e.RowIndex);
if (dt2.Rows[index][2].ToString() == CheckBoxList1.Items[0].Text.ToString())
{
CheckBoxList1.Items[0].Enabled = true;
}
else if (dt2.Rows[index][2].ToString() == CheckBoxList1.Items[1].Text.ToString())
{
CheckBoxList1.Items[1].Enabled = true;
}
else if (dt2.Rows[index][2].ToString() == CheckBoxList1.Items[2].Text.ToString())
{
CheckBoxList1.Items[2].Enabled = true;
}
else if (dt2.Rows[index][2].ToString() == CheckBoxList1.Items[3].Text.ToString())
{
CheckBoxList1.Items[3].Enabled = true;
}
else if (dt2.Rows[index][2].ToString() == CheckBoxList1.Items[4].Text.ToString())
{
CheckBoxList1.Items[4].Enabled = true;
}
else if (dt2.Rows[index][2].ToString() == CheckBoxList1.Items[5].Text.ToString())
{
CheckBoxList1.Items[5].Enabled = true;
}
dt2.Rows[index].Delete();
string task_no = ((Label)GridView3.Rows[e.RowIndex].FindControl("LBL_TASKNO")).Text;
tskctrl.deleteTaskNoDetail(task_no);
GV3DataBinding(lbl_pTask.Text.ToString());
}