ghyath我只在rowdatabound控件中做,但事情就是每当我禁用第1页的第3行时它会自动禁用我想要的第3,第3,第4 ......页面的第3行
答案 0 :(得分:1)
您可以使用PageIndex
和RowIndex
属性:
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);
}
}
如果要禁用单击按钮的行,请使用以下方法:
protected void BtnDisableRow_Click(object sender, EventArgs e)
{
GridViewRow row = (GridViewRow)((Button) sender).NamingContainer;
row.Enabled = false;
}
答案 1 :(得分:0)
使用RowDataBound事件>>
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;
}
}
}