asp:GridView控件的使用
2018-06-22 07:32:42来源:未知 阅读 ()
使用asp:GridView显示一个统计的表格
cs样式:
<style>
table.gridview_m
{
border-collapse: collapse;
border: solid 1px #93c2f1;
width: 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';width:250px;'>营地名称</th><th rowspan='2' style='text-align:center;background:#2dcc70;width:50px;'>国家</th>";
headtxt += "<th colspan='3' style='text-align:center;background:#02dab1;width:100px;'><span style='text-align:center;color:#000000'>本年</span></th>";
headtxt += "<th colspan='3' style='text-align:center;background:#f8c049;width:100px;'><span style='text-align:center;color:#000000'>去年</span></th>";
headtxt += "<th colspan='4' style='text-align:center;background:#fb855d;width: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);
}
}
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- asp.net源程序编译为dll文件并调用的实现过程 2020-03-29
- Asp.net MVC SignalR来做实时Web聊天实例代码 2020-03-29
- ASP.NET MVC中jQuery与angularjs混合应用传参并绑定数据 2020-03-29
- Asp.Net中WebForm的生命周期 2020-03-29
- WPF实现带全选复选框的列表控件 2020-03-29
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash