To Enable/Disable asp.net Gridview Checkbox base on conditions just follow simple way
Suppose you placed agridview in the page as follows
Suppose you placed agridview in the page as follows
<asp:GridView id="GridView1" runat="Server" OnRowCreated="GridView1_OnRowCreated" autogenerateColumns="false"/>
Name | Student ID | marks | Status | |
CheckBox | Yourname | 001 | 200 | F |
CheckBox | Myname | 002 | 800 | P |
CheckBox | Ourname | 003 | 500 | F |
protected void GridView1_OnRowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.DataItem != null)
{
DataRowView drv = (DataRowView)e.Row.DataItem;
string catName = Convert.ToString(drv["Status"]);
if (catName.Trim() == "F")
{
CheckBox cb = (CheckBox)e.Row.FindControl("chkavail");
cb.Enabled = false;
}
}
}
No comments:
Post a Comment