0

如果 sVal 包含当前行的“字段名称”,我需要更新前一行的单元格 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;

        }
    }
4

1 回答 1

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;

    }
}
于 2013-03-10T05:01:32.673 回答