| 订阅 | 在线投稿
分享
 
 
 

ASP.NET 2.0中合并 GridView 的表头单元格

来源:互联网网民  宽屏版  评论
2006-12-11 21:23:39

在实际工作中,往往需要合并表格头部的单元格,下面就是一个实现的例子。运行结果如图:

ASP.NET 2.0中合并 GridView 的表头单元格

C#

ASP.NET 2.0中合并 GridView 的表头单元格
ASP.NET 2.0中合并 GridView 的表头单元格
<%...@ Page Language="C#" AutoEventWireup="true" %>
ASP.NET 2.0中合并 GridView 的表头单元格

ASP.NET 2.0中合并 GridView 的表头单元格
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
ASP.NET 2.0中合并 GridView 的表头单元格
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
ASP.NET 2.0中合并 GridView 的表头单元格

ASP.NET 2.0中合并 GridView 的表头单元格
ASP.NET 2.0中合并 GridView 的表头单元格
<script runat="server">...
ASP.NET 2.0中合并 GridView 的表头单元格
ICollection CreateDataSource()
ASP.NET 2.0中合并 GridView 的表头单元格
ASP.NET 2.0中合并 GridView 的表头单元格
...{
ASP.NET 2.0中合并 GridView 的表头单元格
System.Data.DataTable dt = new System.Data.DataTable();
ASP.NET 2.0中合并 GridView 的表头单元格
System.Data.DataRow dr;
ASP.NET 2.0中合并 GridView 的表头单元格
dt.Columns.Add(new System.Data.DataColumn("学生姓名", typeof(System.String)));
ASP.NET 2.0中合并 GridView 的表头单元格
dt.Columns.Add(new System.Data.DataColumn("语文", typeof(System.Decimal)));
ASP.NET 2.0中合并 GridView 的表头单元格
dt.Columns.Add(new System.Data.DataColumn("数学", typeof(System.Decimal)));
ASP.NET 2.0中合并 GridView 的表头单元格
dt.Columns.Add(new System.Data.DataColumn("英语", typeof(System.Decimal)));
ASP.NET 2.0中合并 GridView 的表头单元格
for (int i = 0; i < 8; i++)
ASP.NET 2.0中合并 GridView 的表头单元格
ASP.NET 2.0中合并 GridView 的表头单元格
...{
ASP.NET 2.0中合并 GridView 的表头单元格
System.Random rd = new System.Random(Environment.TickCount * i); ;
ASP.NET 2.0中合并 GridView 的表头单元格
dr = dt.NewRow();
ASP.NET 2.0中合并 GridView 的表头单元格
dr[0] = "学生" + i.ToString();
ASP.NET 2.0中合并 GridView 的表头单元格
dr[1] = System.Math.Round(rd.NextDouble() * 100, 2);
ASP.NET 2.0中合并 GridView 的表头单元格
dr[2] = System.Math.Round(rd.NextDouble() * 100, 2);
ASP.NET 2.0中合并 GridView 的表头单元格
dr[3] = System.Math.Round(rd.NextDouble() * 100, 2);
ASP.NET 2.0中合并 GridView 的表头单元格
dt.Rows.Add(dr);
ASP.NET 2.0中合并 GridView 的表头单元格
}
ASP.NET 2.0中合并 GridView 的表头单元格
System.Data.DataView dv = new System.Data.DataView(dt);
ASP.NET 2.0中合并 GridView 的表头单元格
return dv;
ASP.NET 2.0中合并 GridView 的表头单元格
}
ASP.NET 2.0中合并 GridView 的表头单元格

ASP.NET 2.0中合并 GridView 的表头单元格
protected void Page_Load(object sender, EventArgs e)
ASP.NET 2.0中合并 GridView 的表头单元格
ASP.NET 2.0中合并 GridView 的表头单元格
...{
ASP.NET 2.0中合并 GridView 的表头单元格
if (!IsPostBack)
ASP.NET 2.0中合并 GridView 的表头单元格
ASP.NET 2.0中合并 GridView 的表头单元格
...{
ASP.NET 2.0中合并 GridView 的表头单元格

ASP.NET 2.0中合并 GridView 的表头单元格
GridView1.BorderColor = System.Drawing.Color.DarkOrange;
ASP.NET 2.0中合并 GridView 的表头单元格
GridView1.DataSource = CreateDataSource();
ASP.NET 2.0中合并 GridView 的表头单元格
GridView1.DataBind();
ASP.NET 2.0中合并 GridView 的表头单元格
}
ASP.NET 2.0中合并 GridView 的表头单元格
}
ASP.NET 2.0中合并 GridView 的表头单元格

ASP.NET 2.0中合并 GridView 的表头单元格
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
ASP.NET 2.0中合并 GridView 的表头单元格
ASP.NET 2.0中合并 GridView 的表头单元格
...{
ASP.NET 2.0中合并 GridView 的表头单元格
if (e.Row.RowType == DataControlRowType.Header)
ASP.NET 2.0中合并 GridView 的表头单元格
ASP.NET 2.0中合并 GridView 的表头单元格
...{
ASP.NET 2.0中合并 GridView 的表头单元格
GridViewRow rowHeader = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal);
ASP.NET 2.0中合并 GridView 的表头单元格
rowHeader.BackColor = System.Drawing.Color.White;
ASP.NET 2.0中合并 GridView 的表头单元格
rowHeader.Font.Bold = true;
ASP.NET 2.0中合并 GridView 的表头单元格

ASP.NET 2.0中合并 GridView 的表头单元格
TableCellCollection cells = e.Row.Cells;
ASP.NET 2.0中合并 GridView 的表头单元格
TableCell headerCell = new TableCell();
ASP.NET 2.0中合并 GridView 的表头单元格
headerCell.Text = "";
ASP.NET 2.0中合并 GridView 的表头单元格
rowHeader.Cells.Add(headerCell);
ASP.NET 2.0中合并 GridView 的表头单元格

ASP.NET 2.0中合并 GridView 的表头单元格
headerCell = new TableCell();
ASP.NET 2.0中合并 GridView 的表头单元格
headerCell.Text = "学生成绩";
ASP.NET 2.0中合并 GridView 的表头单元格
headerCell.ColumnSpan = cells.Count - 1;
ASP.NET 2.0中合并 GridView 的表头单元格
headerCell.HorizontalAlign = HorizontalAlign.Center;
ASP.NET 2.0中合并 GridView 的表头单元格

ASP.NET 2.0中合并 GridView 的表头单元格
rowHeader.Cells.Add(headerCell);
ASP.NET 2.0中合并 GridView 的表头单元格
rowHeader.Visible = true;
ASP.NET 2.0中合并 GridView 的表头单元格
GridView1.Controls[0].Controls.AddAt(0, rowHeader);
ASP.NET 2.0中合并 GridView 的表头单元格
}
ASP.NET 2.0中合并 GridView 的表头单元格
}
ASP.NET 2.0中合并 GridView 的表头单元格

ASP.NET 2.0中合并 GridView 的表头单元格
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
ASP.NET 2.0中合并 GridView 的表头单元格
ASP.NET 2.0中合并 GridView 的表头单元格
...{
ASP.NET 2.0中合并 GridView 的表头单元格
e.Row.Attributes.Add("style", "background:#FFF");
ASP.NET 2.0中合并 GridView 的表头单元格
}
ASP.NET 2.0中合并 GridView 的表头单元格
</script>
ASP.NET 2.0中合并 GridView 的表头单元格

ASP.NET 2.0中合并 GridView 的表头单元格
<html xmlns="http://www.w3.org/1999/xhtml">
ASP.NET 2.0中合并 GridView 的表头单元格
<head>
ASP.NET 2.0中合并 GridView 的表头单元格
<title>合并 GridView 的表头单元格</title>
ASP.NET 2.0中合并 GridView 的表头单元格
</head>
ASP.NET 2.0中合并 GridView 的表头单元格
<body>
ASP.NET 2.0中合并 GridView 的表头单元格
<form id="Form1" runat="server">
ASP.NET 2.0中合并 GridView 的表头单元格
<asp:GridView ID="GridView1" runat="server" CellSpacing="1" CellPadding="3"
ASP.NET 2.0中合并 GridView 的表头单元格
Font-Size="12px" Width="300px" BackColor="orange" BorderWidth="0"
ASP.NET 2.0中合并 GridView 的表头单元格
OnRowDataBound="GridView1_RowDataBound" OnRowCreated="GridView1_RowCreated">
ASP.NET 2.0中合并 GridView 的表头单元格
</asp:GridView>
ASP.NET 2.0中合并 GridView 的表头单元格
</form>
ASP.NET 2.0中合并 GridView 的表头单元格
</body>
ASP.NET 2.0中合并 GridView 的表头单元格
</html>
ASP.NET 2.0中合并 GridView 的表头单元格

VB.NET

ASP.NET 2.0中合并 GridView 的表头单元格
ASP.NET 2.0中合并 GridView 的表头单元格
<%...@ Page Language="VB" %>
ASP.NET 2.0中合并 GridView 的表头单元格

ASP.NET 2.0中合并 GridView 的表头单元格
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
ASP.NET 2.0中合并 GridView 的表头单元格

ASP.NET 2.0中合并 GridView 的表头单元格
ASP.NET 2.0中合并 GridView 的表头单元格
<script runat="server">...
ASP.NET 2.0中合并 GridView 的表头单元格
Function CreateDataSource() As ICollection
ASP.NET 2.0中合并 GridView 的表头单元格
Dim dt As System.Data.DataTable = New System.Data.DataTable
ASP.NET 2.0中合并 GridView 的表头单元格
Dim dr As System.Data.DataRow
ASP.NET 2.0中合并 GridView 的表头单元格
dt.Columns.Add(New System.Data.DataColumn("学生姓名", GetType(System.String)))
ASP.NET 2.0中合并 GridView 的表头单元格
dt.Columns.Add(New System.Data.DataColumn("语文", GetType(System.Decimal)))
ASP.NET 2.0中合并 GridView 的表头单元格
dt.Columns.Add(New System.Data.DataColumn("数学", GetType(System.Decimal)))
ASP.NET 2.0中合并 GridView 的表头单元格
dt.Columns.Add(New System.Data.DataColumn("英语", GetType(System.Decimal)))
ASP.NET 2.0中合并 GridView 的表头单元格
Dim i As Integer = 0
ASP.NET 2.0中合并 GridView 的表头单元格
For i = 0 To 7
ASP.NET 2.0中合并 GridView 的表头单元格
Dim rd As System.Random = New System.Random(Environment.TickCount * i)
ASP.NET 2.0中合并 GridView 的表头单元格

ASP.NET 2.0中合并 GridView 的表头单元格
dr = dt.NewRow
ASP.NET 2.0中合并 GridView 的表头单元格
dr(0) = "学生" + i.ToString
ASP.NET 2.0中合并 GridView 的表头单元格
dr(1) = System.Math.Round(rd.NextDouble * 100, 2)
ASP.NET 2.0中合并 GridView 的表头单元格
dr(2) = System.Math.Round(rd.NextDouble * 100, 2)
ASP.NET 2.0中合并 GridView 的表头单元格
dr(3) = System.Math.Round(rd.NextDouble * 100, 2)
ASP.NET 2.0中合并 GridView 的表头单元格
dt.Rows.Add(dr)
ASP.NET 2.0中合并 GridView 的表头单元格
Next
ASP.NET 2.0中合并 GridView 的表头单元格
Dim dv As System.Data.DataView = New System.Data.DataView(dt)
ASP.NET 2.0中合并 GridView 的表头单元格
Return dv
ASP.NET 2.0中合并 GridView 的表头单元格
End Function
ASP.NET 2.0中合并 GridView 的表头单元格

ASP.NET 2.0中合并 GridView 的表头单元格
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
ASP.NET 2.0中合并 GridView 的表头单元格
If Not IsPostBack Then
ASP.NET 2.0中合并 GridView 的表头单元格
GridView1.BorderColor = System.Drawing.Color.DarkOrange
ASP.NET 2.0中合并 GridView 的表头单元格
GridView1.DataSource = CreateDataSource()
ASP.NET 2.0中合并 GridView 的表头单元格
GridView1.DataBind()
ASP.NET 2.0中合并 GridView 的表头单元格
End If
ASP.NET 2.0中合并 GridView 的表头单元格
End Sub
ASP.NET 2.0中合并 GridView 的表头单元格

ASP.NET 2.0中合并 GridView 的表头单元格
Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
ASP.NET 2.0中合并 GridView 的表头单元格
If e.Row.RowType = DataControlRowType.Header Then
ASP.NET 2.0中合并 GridView 的表头单元格
Dim rowHeader As GridViewRow = New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal)
ASP.NET 2.0中合并 GridView 的表头单元格
rowHeader.BackColor = System.Drawing.Color.White
ASP.NET 2.0中合并 GridView 的表头单元格
rowHeader.Font.Bold = True
ASP.NET 2.0中合并 GridView 的表头单元格
Dim cells As TableCellCollection = e.Row.Cells
ASP.NET 2.0中合并 GridView 的表头单元格
Dim headerCell As TableCell = New TableCell
ASP.NET 2.0中合并 GridView 的表头单元格
headerCell.Text = ""
ASP.NET 2.0中合并 GridView 的表头单元格
rowHeader.Cells.Add(headerCell)
ASP.NET 2.0中合并 GridView 的表头单元格
headerCell = New TableCell
ASP.NET 2.0中合并 GridView 的表头单元格
headerCell.Text = "学生成绩"
ASP.NET 2.0中合并 GridView 的表头单元格
headerCell.ColumnSpan = cells.Count - 1
ASP.NET 2.0中合并 GridView 的表头单元格
headerCell.HorizontalAlign = HorizontalAlign.Center
ASP.NET 2.0中合并 GridView 的表头单元格
rowHeader.Cells.Add(headerCell)
ASP.NET 2.0中合并 GridView 的表头单元格
rowHeader.Visible = True
ASP.NET 2.0中合并 GridView 的表头单元格
GridView1.Controls(0).Controls.AddAt(0, rowHeader)
ASP.NET 2.0中合并 GridView 的表头单元格
End If
ASP.NET 2.0中合并 GridView 的表头单元格
End Sub
ASP.NET 2.0中合并 GridView 的表头单元格

ASP.NET 2.0中合并 GridView 的表头单元格
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
ASP.NET 2.0中合并 GridView 的表头单元格
e.Row.Attributes.Add("style", "background:#FFF")
ASP.NET 2.0中合并 GridView 的表头单元格
End Sub
ASP.NET 2.0中合并 GridView 的表头单元格

ASP.NET 2.0中合并 GridView 的表头单元格
</script>
ASP.NET 2.0中合并 GridView 的表头单元格

ASP.NET 2.0中合并 GridView 的表头单元格
<html xmlns="http://www.w3.org/1999/xhtml">
ASP.NET 2.0中合并 GridView 的表头单元格
<head>
ASP.NET 2.0中合并 GridView 的表头单元格
<title>合并 GridView 的表头单元格</title>
ASP.NET 2.0中合并 GridView 的表头单元格
</head>
ASP.NET 2.0中合并 GridView 的表头单元格
<body>
ASP.NET 2.0中合并 GridView 的表头单元格
<form id="Form1" runat="server">
ASP.NET 2.0中合并 GridView 的表头单元格
<asp:GridView ID="GridView1" runat="server" CellSpacing="1" CellPadding="3"
ASP.NET 2.0中合并 GridView 的表头单元格
Font-Size="12px" Width="300px" BackColor="orange" BorderWidth="0"
ASP.NET 2.0中合并 GridView 的表头单元格
OnRowDataBound="GridView1_RowDataBound" OnRowCreated="GridView1_RowCreated">
ASP.NET 2.0中合并 GridView 的表头单元格
</asp:GridView>
ASP.NET 2.0中合并 GridView 的表头单元格
</form>
ASP.NET 2.0中合并 GridView 的表头单元格
</body>
ASP.NET 2.0中合并 GridView 的表头单元格
</html>
ASP.NET 2.0中合并 GridView 的表头单元格

 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
在实际工作中,往往需要合并表格头部的单元格,下面就是一个实现的例子。运行结果如图: [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://dotnet.aspx.cc/article/ColumnSpan.gif[/img][/url] C# [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif[/img][/url][url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif[/img][/url]<%...@ Page Language="C#" AutoEventWireup="true" %> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif[/img][/url][url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif[/img][/url]<script runat="server">... [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] ICollection CreateDataSource() [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif[/img][/url][url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif[/img][/url] ...{ [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] System.Data.DataTable dt = new System.Data.DataTable(); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] System.Data.DataRow dr; [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dt.Columns.Add(new System.Data.DataColumn("学生姓名", typeof(System.String))); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dt.Columns.Add(new System.Data.DataColumn("语文", typeof(System.Decimal))); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dt.Columns.Add(new System.Data.DataColumn("数学", typeof(System.Decimal))); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dt.Columns.Add(new System.Data.DataColumn("英语", typeof(System.Decimal))); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] for (int i = 0; i < 8; i++) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif[/img][/url][url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif[/img][/url] ...{ [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] System.Random rd = new System.Random(Environment.TickCount * i); ; [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dr = dt.NewRow(); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dr[0] = "学生" + i.ToString(); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dr[1] = System.Math.Round(rd.NextDouble() * 100, 2); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dr[2] = System.Math.Round(rd.NextDouble() * 100, 2); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dr[3] = System.Math.Round(rd.NextDouble() * 100, 2); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dt.Rows.Add(dr); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif[/img][/url] } [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] System.Data.DataView dv = new System.Data.DataView(dt); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] return dv; [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif[/img][/url] } [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] protected void Page_Load(object sender, EventArgs e) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif[/img][/url][url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif[/img][/url] ...{ [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] if (!IsPostBack) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif[/img][/url][url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif[/img][/url] ...{ [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] GridView1.BorderColor = System.Drawing.Color.DarkOrange; [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] GridView1.DataSource = CreateDataSource(); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] GridView1.DataBind(); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif[/img][/url] } [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif[/img][/url] } [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif[/img][/url][url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif[/img][/url] ...{ [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] if (e.Row.RowType == DataControlRowType.Header) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif[/img][/url][url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif[/img][/url] ...{ [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] GridViewRow rowHeader = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] rowHeader.BackColor = System.Drawing.Color.White; [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] rowHeader.Font.Bold = true; [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] TableCellCollection cells = e.Row.Cells; [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] TableCell headerCell = new TableCell(); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] headerCell.Text = ""; [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] rowHeader.Cells.Add(headerCell); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] headerCell = new TableCell(); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] headerCell.Text = "学生成绩"; [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] headerCell.ColumnSpan = cells.Count - 1; [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] headerCell.HorizontalAlign = HorizontalAlign.Center; [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] rowHeader.Cells.Add(headerCell); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] rowHeader.Visible = true; [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] GridView1.Controls[0].Controls.AddAt(0, rowHeader); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif[/img][/url] } [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif[/img][/url] } [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif[/img][/url][url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif[/img][/url] ...{ [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] e.Row.Attributes.Add("style", "background:#FFF"); [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif[/img][/url] } [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]</script> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]<html xmlns="http://www.w3.org/1999/xhtml"> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]<head> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] <title>合并 GridView 的表头单元格</title> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]</head> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]<body> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] <form id="Form1" runat="server"> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] <asp:GridView ID="GridView1" runat="server" CellSpacing="1" CellPadding="3" [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] Font-Size="12px" Width="300px" BackColor="orange" BorderWidth="0" [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] OnRowDataBound="GridView1_RowDataBound" OnRowCreated="GridView1_RowCreated"> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] </asp:GridView> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] </form> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]</body> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]</html> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] VB.NET [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif[/img][/url][url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif[/img][/url]<%...@ Page Language="VB" %> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif[/img][/url][url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif[/img][/url]<script runat="server">... [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] Function CreateDataSource() As ICollection [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] Dim dt As System.Data.DataTable = New System.Data.DataTable [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] Dim dr As System.Data.DataRow [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dt.Columns.Add(New System.Data.DataColumn("学生姓名", GetType(System.String))) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dt.Columns.Add(New System.Data.DataColumn("语文", GetType(System.Decimal))) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dt.Columns.Add(New System.Data.DataColumn("数学", GetType(System.Decimal))) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dt.Columns.Add(New System.Data.DataColumn("英语", GetType(System.Decimal))) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] Dim i As Integer = 0 [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] For i = 0 To 7 [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] Dim rd As System.Random = New System.Random(Environment.TickCount * i) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dr = dt.NewRow [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dr(0) = "学生" + i.ToString [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dr(1) = System.Math.Round(rd.NextDouble * 100, 2) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dr(2) = System.Math.Round(rd.NextDouble * 100, 2) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dr(3) = System.Math.Round(rd.NextDouble * 100, 2) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] dt.Rows.Add(dr) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] Next [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] Dim dv As System.Data.DataView = New System.Data.DataView(dt) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] Return dv [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] End Function [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] If Not IsPostBack Then [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] GridView1.BorderColor = System.Drawing.Color.DarkOrange [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] GridView1.DataSource = CreateDataSource() [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] GridView1.DataBind() [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] End If [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] End Sub [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] If e.Row.RowType = DataControlRowType.Header Then [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] Dim rowHeader As GridViewRow = New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] rowHeader.BackColor = System.Drawing.Color.White [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] rowHeader.Font.Bold = True [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] Dim cells As TableCellCollection = e.Row.Cells [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] Dim headerCell As TableCell = New TableCell [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] headerCell.Text = "" [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] rowHeader.Cells.Add(headerCell) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] headerCell = New TableCell [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] headerCell.Text = "学生成绩" [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] headerCell.ColumnSpan = cells.Count - 1 [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] headerCell.HorizontalAlign = HorizontalAlign.Center [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] rowHeader.Cells.Add(headerCell) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] rowHeader.Visible = True [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] GridView1.Controls(0).Controls.AddAt(0, rowHeader) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] End If [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] End Sub [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] e.Row.Attributes.Add("style", "background:#FFF") [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] End Sub [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif[/img][/url] [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]</script> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]<html xmlns="http://www.w3.org/1999/xhtml"> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]<head> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] <title>合并 GridView 的表头单元格</title> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]</head> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]<body> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] <form id="Form1" runat="server"> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] <asp:GridView ID="GridView1" runat="server" CellSpacing="1" CellPadding="3" [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] Font-Size="12px" Width="300px" BackColor="orange" BorderWidth="0" [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] OnRowDataBound="GridView1_RowDataBound" OnRowCreated="GridView1_RowCreated"> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] </asp:GridView> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] </form> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]</body> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]</html> [url=http://www.wangchao.net.cn/bbsdetail_566598.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]
󰈣󰈤
 
 
 
>>返回首页<<
 
 热帖排行
 
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
©2005- 王朝网络 版权所有