C#多个标题头合并
2021/9/5 22:08:30
本文主要是介绍C#多个标题头合并,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.Header: //总表头 TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); //第一行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[0].Attributes.Add("bgcolor", "DarkSeaBlue"); tcHeader[0].Attributes.Add("colspan", "6"); //合并第一行的6列 tcHeader[0].Text = "用户基本信息</th></tr><tr>"; //第二行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[1].Attributes.Add("bgcolor", "DarkSeaGreen"); tcHeader[1].Attributes.Add("colspan", "3"); tcHeader[1].Text = "基本信息"; tcHeader.Add(new TableHeaderCell()); tcHeader[2].Attributes.Add("bgcolor", "DarkSeaGreen"); tcHeader[2].Attributes.Add("colspan", "3"); tcHeader[2].Text = "籍贯信息</th></tr><tr>"; //第三行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[3].Attributes.Add("bgcolor", "Khaki"); tcHeader[3].Text = "公司"; tcHeader.Add(new TableHeaderCell()); tcHeader[4].Attributes.Add("bgcolor", "Khaki"); tcHeader[4].Text = "姓名"; tcHeader.Add(new TableHeaderCell()); tcHeader[5].Attributes.Add("bgcolor", "Khaki"); tcHeader[5].Text = "职衔"; tcHeader.Add(new TableHeaderCell()); tcHeader[6].Attributes.Add("bgcolor", "Khaki"); tcHeader[6].Text = "住址"; tcHeader.Add(new TableHeaderCell()); tcHeader[7].Attributes.Add("bgcolor", "Khaki"); tcHeader[7].Text = "城市"; tcHeader.Add(new TableHeaderCell()); tcHeader[8].Attributes.Add("bgcolor", "Khaki"); tcHeader[8].Text = "国籍"; break; } } <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource1" GridLines="Vertical" Width="927px" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" onrowcreated="GridView1_RowCreated" ForeColor="Black"> <RowStyle BackColor="#F7F7DE" /> <Columns> <asp:BoundField DataField="CompanyName" HeaderText="公司" /> <asp:BoundField DataField="ContactName" HeaderText="姓名" /> <asp:BoundField DataField="ContactTitle" HeaderText="职衔" /> <asp:BoundField DataField="Address" HeaderText="住址" /> <asp:BoundField DataField="City" HeaderText="居住地" /> <asp:BoundField DataField="Country" HeaderText="国籍" SortExpression="Country" /> </Columns> <FooterStyle BackColor="#CCCC99" /> <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" /> <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="White" /> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [CompanyName], [ContactName], [ContactTitle], [Address], [City], [Country] FROM [Customers]"> </asp:SqlDataSource>
这篇关于C#多个标题头合并的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2022-03-01沐雪多租宝商城源码从.NetCore3.1升级到.Net6的步骤
- 2024-12-06使用Microsoft.Extensions.AI在.NET中生成嵌入向量
- 2024-11-18微软研究:RAG系统的四个层次提升理解与回答能力
- 2024-11-15C#中怎么从PEM格式的证书中提取公钥?-icode9专业技术文章分享
- 2024-11-14云架构设计——如何用diagrams.net绘制专业的AWS架构图?
- 2024-05-08首个适配Visual Studio平台的国产智能编程助手CodeGeeX正式上线!C#程序员必备效率神器!
- 2024-03-30C#设计模式之十六迭代器模式(Iterator Pattern)【行为型】
- 2024-03-29c# datetime tryparse
- 2024-02-21list find index c#
- 2024-01-24convert toint32 c#