All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
根据主键,合并gridview的行_[Asp.Net教程]

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/1/30 1:37:27 Browse times: 275 Comment times: 0

根据主键,合并gridview的行_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

根据主键,合并gridview的行_[Asp.Net教程] /// 要合并行的gridview
/// 要合并行的列集合
/// 合并所依据的主键
public static void GroupRows(GridView GridView1, int[] cellNums, string keyname)
{
int i = 0, rowSpanNum = 1;
while (i {
GridViewRow gvr = GridView1.Rows[i];
for (++i; i < GridView1.Rows.Count; i++)
{
GridViewRow gvrNext = GridView1.Rows[i];
if (GridView1.DataKeys[i - 1][keyname].ToString() == GridView1.DataKeys[i][keyname].ToString())
{
for (int s = 0; s < cellNums.Length; s++)
{
gvrNext.Cells[cellNums[s]].Visible = false;
}
rowSpanNum++;
}
else
{
for (int s = 0; s < cellNums.Length; s++)
{
gvr.Cells[cellNums[s]].RowSpan = rowSpanNum;
}
rowSpanNum = 1;
break;
}
if (i == GridView1.Rows.Count - 1)
{
for (int s = 0; s < cellNums.Length; s++)
{
gvr.Cells[cellNums[s]].RowSpan = rowSpanNum;
}
}
}
}
}




There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.