我正在尝试使用asp.net制作网格视图。我希望列的标题有一个像这样的colspan:
但就目前而言:
我的代码是:
<asp:GridView ID="GV" runat="server" AutoGenerateColumns="false" OnPreRender="gridView_PreRender">
<Columns>
<asp:BoundField HeaderText="" />
<asp:BoundField HeaderText="Num OF" DataField="cod_wo" />
<asp:BoundField HeaderText="Num Seq" DataField="dat_sequence" />
<asp:BoundField HeaderText="Article" DataField="article"/>
<asp:BoundField HeaderText="Qté OF Prévue" DataField="wo_qty" />
<asp:BoundField HeaderText="Qté OF Revue" DataField="qty_revue" />
<asp:BoundField HeaderText="Composant" DataField="composant" />
<asp:BoundField HeaderText="Restant à assigner" DataField="restant_a_assigner" />
<asp:BoundField HeaderText="Assignation HU" />
<asp:BoundField HeaderText="Qté totale" DataField="qte_totale_assignee" />
<asp:BoundField HeaderText="Num HU" DataField="num_hu" />
<asp:BoundField HeaderText="Qté" DataField="qte_assignee" />
</Columns>
</asp:GridView>
在C#后面的代码中我有:
public static void MergeColumns(GridView gridView)
{
gridView.HeaderRow.Cells[0].RowSpan = 2;
gridView.HeaderRow.Cells[1].RowSpan = 2;
gridView.HeaderRow.Cells[2].RowSpan = 2;
gridView.HeaderRow.Cells[3].RowSpan = 2;
gridView.HeaderRow.Cells[4].RowSpan = 2;
gridView.HeaderRow.Cells[5].RowSpan = 2;
gridView.HeaderRow.Cells[6].RowSpan = 2;
gridView.HeaderRow.Cells[7].RowSpan = 2;
gridView.HeaderRow.Cells[8].ColumnSpan = 3;
}
你知道吗?感谢