在rowdatabound事件上设置行数据

时间:2012-10-02 22:10:45

标签: c# .net gridview

我有id="table_results_header"内的表ItemTemplate。是否有可能使用rowdatabound事件来调用封装网格视图的每一行上发生的该表的实例,以便我可以以编程方式操作这些样式?

if (e.Row.RowType == DataControlRowType.DataRow)
{
    however_you_get_to_the_table.BackColor = System.Drawing.Color.Blue;
}

我真的很想知道是否可以这样做?

由于

1 个答案:

答案 0 :(得分:2)

是的,您可以使用FindControl

if (e.Row.RowType == DataControlRowType.DataRow)
{
  ((Table)e.Row.FindControl("table_results_header")).BackColor = Color.Blue;
}