判断本页的行数,添加空行
代码需要整理下再用
- C# code
- <!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->
protected void GrvCode_RowCreated(object sender, GridViewRowEventArgs e)
{
int num = 0;
num = GrvCode.Rows.Count;
if (e.Row.RowType == DataControlRowType.Footer)
{
int left = GrvCode.PageSize - num;
int numCol = GrvCode.Rows[0].Cells.Count;
for(int i=0;i<left;i++)
{
GridViewRow row =
new GridViewRow(-1,-1,DataControlRowType.EmptyDataRow,DataControlRowState.Normal);
for (int j = 0; j < numCol; j++)
{
TableCell cell = new TableCell();
cell.Text = " ";
row.Cells.Add(cell);
}
GrvCode.Controls[0].Controls.AddAt(num+1+i,row);
}
}
}
代码需要整理下再用
本文介绍了一段C#代码,用于判断GridView控件当前页面的行数,并在页脚添加足够的空行以填充剩余的空间。该方法适用于需要在GridView中保持每页行数一致的场景。
182

被折叠的 条评论
为什么被折叠?



