1
如果sVal包含當前行的「字段名稱」,我需要更新上一行的單元格4以添加按鈕單擊事件。如何更新以前的gridview行onrowdatabound
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;
}
}
GridView控件是動態創建。 – Sammy 2013-03-10 05:05:32