如何更新以前的gridview行rowdatabound

时间:2013-03-10 04:38:36

标签: c# asp.net gridview

如果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;

        }
    }

1 个答案:

答案 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;

    }
}