Reputation: 3005
ghyath i am doing in rowdatabound control only but the thing is that whenever i disabled 3rd row of the 1st page it automatically disable the 3rd row of 2nd, 3rd, 4th..... page which i dnt want
Upvotes: 1
Views: 4862
Reputation: 460068
You can use the PageIndex
and RowIndex
properties:
protected void MyGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
var grid = (GridView) sender;
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Enabled = (grid.PageIndex != 0 || e.Row.RowIndex != 2);
}
}
If you want to disable the row of a button that was clicked use this approach:
protected void BtnDisableRow_Click(object sender, EventArgs e)
{
GridViewRow row = (GridViewRow)((Button) sender).NamingContainer;
row.Enabled = false;
}
Upvotes: 1
Reputation: 16219
use RowDataBound event >>
protected void gvLeaveDetail_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { string status = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "3rdROW"));
if(status== "accept")
{
// Cells[7] : 3rd Row then it should be '4' then it will work on only that row
e.Row.Cells[7].ForeColor = System.Drawing.Color.Green;
}
else if (status == "reject")
{
e.Row.Cells[7].ForeColor = System.Drawing.Color.Red;
}
}
}
Upvotes: 0