How to make enable/disable particular row cell of Gridview ?



Hi
In our daily coding, so many time we have to do particular action in some particular cell. For example we have to do enable/disable some row cell of Gridview on some condition. Then we can do like this
Step1: Click on onrowdatabound event of Grid
Step2: Write the code in code behind like this

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{

Button btn1 = (Button)e.Row.FindControl(“BtnSubmit”);

if (e.Row.RowType == DataControlRowType.DataRow)
{

Label LblEmpSal = (Label)e.Row.FindControl(“lblEmpSal”);
if (LblEmpSal.Text == “15000”)
{
btn1.Enabled = false;
}

}

}

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.