如何动态增加DataGrid的样式属性????
在.aspx中,DataGird就是这样的属性:
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 312px; POSITION: absolute; TOP:
224px"runat="server" >
</asp:DataGrid>
我想通过.aspx.cs代码中为其增加相应的样式,样式如下:
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 312px; POSITION: absolute; TOP:
224px"runat="server" Width="448px" Height="176px">
<selecteditemstyle backcolor="Yellow"></selecteditemstyle>
<alternating itemstylebordercolor="ActiveBorder"backcolor="#FFFFF7">
</alternatingitemstyle>
<itemstyle backcolor="#F7FFF7"></itemstyle>
<headerstyle backcolor="#BDD3EF"></headerstyle>
</asp:DataGrid>
我的代码不知怎么写,原来想这样写,但不对:
DataGrid1.Headerstyle.BackColor.Name="#BDD3EF";
DataGrid1.ItemStyle.BackColor.Name="#F7FFF7";
DataGrid1.Width=448;
DataGrid1.Height=176;
望各位看一下。