按http://www.cnblogs.com/liningx/archive/2009/09/24/1573230.html为GridView增加<colgroup>属性,自定义自己的GridView
添加样式:
<style type="text/css">
.table-box { width: 100%; table-layout: fixed; text-align: center; }
.table-box .Col1 { width: 10%; }
.table-box .Col2 { width: 80%; }
.table-box .Col3 { width: 10%; }
</style>
应用:
<custom:GridViewWithColGroup ID="gvFile" runat="server" AutoGenerateColumns="False"
CssClass="table-box">
<colgrouptemplate>
<COL class="Col1" />
<COL class="Col2" />
<COL class="Col3" />
</colgrouptemplate>
<Columns>
<asp:BoundField DataField="date1" HeaderText="第一列" />
<asp:BoundField DataField="date2" HeaderText="第二列" />
<asp:BoundField DataField="date3" HeaderText="第三列" />
</Columns>
</custom:GridViewWithColGroup>