zoukankan      html  css  js  c++  java
  • asp:GridView控件的使用

    使用asp:GridView显示一个统计的表格

    cs样式:

    <style>
            table.gridview_m
            {
                border-collapse: collapse;
                border: solid 1px #93c2f1;
                100%;
                font-size: 9pt;
                line-height: 24px;
            }
            table.gridview_m td, th
            {
                border-collapse: collapse;
                border: solid 1px #93c2f1;
                font-size: 9pt;
            }
            tr.gridview_row td
            {
                text-align: center;
                font-size: 9pt;
                color: #444;
            }
            input
            {
                border: 1px solid #999;
                padding-left: 3px;
            }
        </style>

    aspx控件

    <asp:GridView ID="GridView1" runat="server"  AutoGenerateColumns="false"
                         Width="100%" border="0" CssClass="gridview_m"
                        OnRowCreated="SmartGridView1_RowCreated">
                        <Columns>
                          <asp:BoundField  DataField="营地编号">
                            <HeaderStyle Width="60px" />
                                <ItemStyle HorizontalAlign="Center" />
                         </asp:BoundField>
                          <asp:BoundField DataField="营地名称">
                                <HeaderStyle Width="30px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="国家">
                                <HeaderStyle Width="60px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                             <asp:BoundField DataField="本年团个数">
                                <HeaderStyle Width="60px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="本年预计人数">
                                <HeaderStyle Width="60px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="本年入库人数">
                                <HeaderStyle Width="60px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                             <asp:BoundField DataField="去年团个数">
                                <HeaderStyle Width="60px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="去年预计人数">
                                <HeaderStyle Width="60px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="去年入库人数">
                                <HeaderStyle Width="60px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                             <asp:BoundField DataField="预订增长数">
                                <HeaderStyle Width="60px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="入库人数增长数">
                                <HeaderStyle Width="60px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                             <asp:BoundField DataField="预订增长率">
                                <HeaderStyle Width="60px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="入库人数增长率">
                                <HeaderStyle Width="60px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            
                        </Columns>
                    </asp:GridView>

    cs程序

    public void SmartGridView1_RowCreated(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.Header)
                {
                    TableCellCollection header = e.Row.Cells;
                    header.Clear();
                    string headtxt = "营地编号</th><th rowspan='2' style='text-align:center;background:#fb855d';250px;'>营地名称</th><th rowspan='2' style='text-align:center;background:#2dcc70;50px;'>国家</th>";
                    headtxt += "<th colspan='3' style='text-align:center;background:#02dab1;100px;'><span style='text-align:center;color:#000000'>本年</span></th>";
                    headtxt += "<th colspan='3' style='text-align:center;background:#f8c049;100px;'><span style='text-align:center;color:#000000'>去年</span></th>";
                    headtxt += "<th colspan='4' style='text-align:center;background:#fb855d;100px;'><span style='text-align:center;color:#000000'>同期增长情况</span></th></tr><tr>";
                    headtxt += "<th style='text-align: center;background:#02dab1'><span style='color:#333333'>团个数</span></th><th  style='text-align: center;background:#02dab1'><span style='color:#333333'>预计人数</span></th><th   style='text-align: center;background:#02dab1'><span style='color:#333333'>入库人数</span></th>";
                    headtxt += "<th style='text-align: center;background:#f8c049'><span style='color:#333333'>团个数</span></th><th  style='text-align: center;background:#f8c049'><span style='color:#333333'>预计人数</span></th><th   style='text-align: center;background:#f8c049'><span style='color:#333333'>入库人数</span></th>";
                    headtxt += "<th  style='text-align: center;background:#fb855d'>预计增长数</th><th style='text-align: center;background:#fb855d'>入库增长数</th><th  style='text-align: center;background:#fb855d'>预计增长率</th><th   style='text-align: center;background:#fb855d'>入库增长率</th></tr><tr>";
                    headtxt += "</tr> ";
                    TableHeaderCell cell = new TableHeaderCell();
                    cell.Attributes.Add("rowspan", "2");  //跨两行

                    cell.Attributes.Add("style", "text-align:center;background:#35bef1");
                    cell.Attributes.Add("width", "50px");
                    cell.Text = headtxt;
                    header.Add(cell);
                }
            }

  • 相关阅读:
    Allegro PCB Design GXL (legacy) 使用slide无法将走线推挤到焊盘的原因
    OrCAD Capture CIS 16.6 导出BOM
    Altium Designer (17.0) 打印输出指定的层
    Allegro PCB Design GXL (legacy) 将指定的层导出为DXF
    Allegro PCB Design GXL (legacy) 设置十字大光标
    Allegro PCB Design GXL (legacy) 手动更改元器件引脚的网络
    magento产品导入时需要注意的事项
    magento url rewrite
    验证台湾同胞身份证信息
    IE8对css文件的限制
  • 原文地址:https://www.cnblogs.com/ly77461/p/5707644.html
Copyright © 2011-2022 走看看