更改gridview asp.net中的数据绑定

时间:2019-06-27 01:23:08

标签: asp.net

如何通过databoud在gridview asp.net中更改颜色/背景色,我这样尝试,发现错误。这个问题有什么解决方案。谢谢

私有子GridView1_RowDataBound(ByVal发送者为对象,ByVal e为System.Web.UI.WebControls.GridViewRowEventArgs)处理GridView1.RowDataBound

        If e.Row.RowType = DataControlRowType.DataRow Then
            If (e.Row.Cells(1).Text) = "102" Then
                e.Row.Cells(1).BackColor = System.Drawing.Color.Red
            End If
        End If
End Sub

1 个答案:

答案 0 :(得分:1)

if (e.Row.Cells[0].Text == "12")
          {
              e.Row.Cells[0].ForeColor = System.Drawing.Color.Red;
          }
else if(e.Row.Cells[0].Text == "13")
          {
              e.Row.Cells[0].ForeColor = System.Drawing.Color.Yellow;
          }