如何更新以前的gridview行onrowboundound
本文关键字:gridview onrowboundound 何更新 更新 | 更新日期: 2023-09-27 18:03:05
我需要更新前一行的单元格4,以便在sVal包含当前行的"字段名"时添加按钮单击事件。
protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string sVal = e.Row.Cells[2].Text;
if (sVal.Contains("Field Name"))
{
// update cell[4] of previous row with button click event
e.Row.Cells[2].BackColor = System.Drawing.Color.WhiteSmoke;
e.Row.Cells[2].Font.Bold = true;
e.Row.Cells[3].BackColor = System.Drawing.Color.WhiteSmoke;
e.Row.Cells[3].Font.Bold = true;
e.Row.Cells[4].BackColor = System.Drawing.Color.WhiteSmoke;
e.Row.Cells[4].Font.Bold = true;
}
}
你需要制作class然后这个类调用update panel在自动更新面板定时器5秒..这是一个好方法……
string sVal = e.Row.Cells[2].Text;
if (sVal.Contains("Field Name"))
{
// update cell[4] of previous row with button click event
e.Row.Cells[2].BackColor = System.Drawing.Color.WhiteSmoke;
e.Row.Cells[2].Font.Bold = true;
e.Row.Cells[3].BackColor = System.Drawing.Color.WhiteSmoke;
e.Row.Cells[3].Font.Bold = true;
e.Row.Cells[4].BackColor = System.Drawing.Color.WhiteSmoke;
e.Row.Cells[4].Font.Bold = true;
}
}