...FunctionCreateDataSource()AsICollectionDimdtAsSystem.Data.DataTabl" />

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

系统 1819 0

<% ... @PageLanguage = " VB " %>

<! DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >

< script runat ="server" > ...
FunctionCreateDataSource()AsICollection
DimdtAsSystem.Data.DataTable
= NewSystem.Data.DataTable
DimdrAsSystem.Data.DataRow
dt.Columns.Add(NewSystem.Data.DataColumn(
" 学生姓名 " ,GetType(System.String)))
dt.Columns.Add(NewSystem.Data.DataColumn(
" 语文 " ,GetType(System.Decimal)))
dt.Columns.Add(NewSystem.Data.DataColumn(
" 数学 " ,GetType(System.Decimal)))
dt.Columns.Add(NewSystem.Data.DataColumn(
" 英语 " ,GetType(System.Decimal)))
DimiAsInteger
= 0
Fori
= 0 To 7
DimrdAsSystem.Random
= NewSystem.Random(Environment.TickCount * i)

dr
= dt.NewRow
dr(
0 ) = " 学生 " + i.ToString
dr(
1 ) = System.Math.Round(rd.NextDouble * 100 , 2 )
dr(
2 ) = System.Math.Round(rd.NextDouble * 100 , 2 )
dr(
3 ) = System.Math.Round(rd.NextDouble * 100 , 2 )
dt.Rows.Add(dr)
Next
DimdvAsSystem.Data.DataView
= NewSystem.Data.DataView(dt)
Returndv
EndFunction

ProtectedSubPage_Load(ByValsenderAsObject,ByValeAsEventArgs)
IfNotIsPostBackThen
GridView1.BorderColor
= System.Drawing.Color.DarkOrange
GridView1.DataSource
= CreateDataSource()
GridView1.DataBind()
EndIf
EndSub

ProtectedSubGridView1_RowCreated(ByValsenderAsObject,ByValeAsGridViewRowEventArgs)
Ife.Row.RowType
= DataControlRowType.HeaderThen
DimrowHeaderAsGridViewRow
= NewGridViewRow( 0 , 0 ,DataControlRowType.Header,DataControlRowState.Normal)
rowHeader.BackColor
= System.Drawing.Color.White
rowHeader.Font.Bold
= True
DimcellsAsTableCellCollection
= e.Row.Cells
DimheaderCellAsTableCell
= NewTableCell
headerCell.Text
= ""
rowHeader.Cells.Add(headerCell)
headerCell
= NewTableCell
headerCell.Text
= " 学生成绩 "
headerCell.ColumnSpan
= cells.Count - 1
headerCell.HorizontalAlign
= HorizontalAlign.Center
rowHeader.Cells.Add(headerCell)
rowHeader.Visible
= True
GridView1.Controls(
0 ).Controls.AddAt( 0 ,rowHeader)
EndIf
EndSub

ProtectedSubGridView1_RowDataBound(ByValsenderAsObject,ByValeAsGridViewRowEventArgs)
e.Row.Attributes.Add(
" style " , " background:#FFF " )
EndSub

</ script >

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

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


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论