asp.net网格颜色设置
我有一个绑定到datatable的gridview。如何编程在绑定完成后更改第1列的颜色?必须在RowDataBound事件中进行绑定时执行此操作 设置事件中第一列单元格的颜色:asp.net网格颜色设置,asp.net,gridview,asp.net-controls,Asp.net,Gridview,Asp.net Controls,我有一个绑定到datatable的gridview。如何编程在绑定完成后更改第1列的颜色?必须在RowDataBound事件中进行绑定时执行此操作 设置事件中第一列单元格的颜色: protected void gridView1_RowDataBound(object sender, GridViewRowEventArgs e) { e.Row.Cells[0].BackColor = Color.Red } 一种方法是处理“OnRowCreated”事件。您可以通过向.aspx中的
protected void gridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[0].BackColor = Color.Red
}
一种方法是处理“OnRowCreated”事件。您可以通过向.aspx中的Gridview声明添加以下内容来完成此操作:
<asp:GridView ID="GridView1" runat="server" OnRowCreated="GridView1_RowCreated" />
“绑定后”是什么意思?如果是“绑定后”,则渲染已完成。
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[1].BackColor = System.Drawing.Color.Blue;
}