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);
                }
            }

  • 相关阅读:
    Linux初级入门(一)
    教育行业----精华网址汇总
    乐高教育版45544零件---分类识别
    乐高ev3编程---书籍选择
    机器人 乐高ev3 arduino 控制器等
    scratch----回家过年
    Scratch2.0例—接苹果
    scratch2绘图编辑器使用--总结
    在舞台上跳舞
    教学设计--我是飞行员
  • 原文地址:https://www.cnblogs.com/ly77461/p/5707644.html
Copyright © 2011-2022 走看看