日期:2014-05-17  浏览次数:20439 次

GridView双层表头应该怎么做?
现在我把我刚写好的单层表头贴一下,就是很普通的GridView+dataTable方式。

前台
HTML code

<asp:GridView ID="gv_EmployeeP" runat="server" AutoGenerateColumns="False" 
                    OnRowDataBound="gv_OrderInfo_RowDataBound">
                    <Columns>
                        <asp:BoundField DataField="客服" HeaderText="客服" ReadOnly="True">
                        <HeaderStyle Font-Bold="True" />
                        <ItemStyle Width="40px" />
                        </asp:BoundField>

                        <asp:BoundField DataField="今日总共" HeaderText="总共" ReadOnly="True">
                        <HeaderStyle Font-Bold="True" />
                        <ItemStyle Width="40px" />
                        </asp:BoundField>

                        <asp:BoundField DataField="今日已到" HeaderText="已到" ReadOnly="True">
                        <HeaderStyle Font-Bold="True" />
                        <ItemStyle Width="40px" />
                        </asp:BoundField>

                        <asp:BoundField DataField="今日未到" HeaderText="未到" ReadOnly="True">
                        <HeaderStyle Font-Bold="True" />
                        <ItemStyle Width="40px" />
                        </asp:BoundField>

                        <asp:BoundField DataField="昨日总共" HeaderText="总共" ReadOnly="True">
                        <HeaderStyle Font-Bold="True" />
                        <ItemStyle Width="40px" />
                        </asp:BoundField>

                        <asp:BoundField DataField="昨日已到" HeaderText="已到" ReadOnly="True">
                        <HeaderStyle Font-Bold="True" />
                        <ItemStyle Width="40px" />
                        </asp:BoundField>

                        <asp:BoundField DataField="昨日未到" HeaderText="未到" ReadOnly="True">
                        <HeaderStyle Font-Bold="True" />
                        <ItemStyle Width="40px" />
                        </asp:BoundField>

                        <asp:BoundField DataField="昨日总共" HeaderText="总共" ReadOnly="True">
                        <HeaderStyle Font-Bold="True" />
                        <ItemStyle Width="40px" />
                        </asp:BoundField>
                    </Columns>
                </asp:GridView>




禁用了自动生成列->AutoGenerateColumns=false

后台生成dataTalble代码如下
C# code

        private DataTable OneSelfData(DataTable _dt)
        {
            DataTable dt = new DataTable("Table_OneSelf");
            dt.Columns.Add("客服", System.Type.GetType("System.String"));

            dt.Columns.Add("今日总共", System.Type.GetType("System.Int32"));
            dt.Columns.Add("今日已到", System.Type.GetType("System.Int32"));
            dt.Columns.Add("今日未到", System.Type.GetType("System.Int32"));

            dt.Columns.Add("昨日总共", System.Type.GetType("System.Int32"));
            
            //。。省略
           
             DataRow dr = dt.NewRow();
           //中间代码省略
            dt.Rows.A