如果sVal包含当前行的“Field Name”,我需要更新上一行的Cell 4以添加按钮单击事件。
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;
}
}
答案 0 :(得分:0)
你需要上课 然后在自动更新面板计时器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;
}
}