//
设置每页显示的行数
int TotalRowCount = 10 ;
// 已经填充的行数
int numCount = 0 ;
protected void GridView1_RowDataBound( object sender, GridViewRowEventArgs e)
... {
if (e.Row.RowType == DataControlRowType.DataRow)
...{
// 计算已经填充的行数
numCount++;
}
if (e.Row.RowType == DataControlRowType.Footer)
...{
// 计算缺少的行数
int toLeft = TotalRowCount - numCount;
// 计算列数
int numCols = GridView1.Rows[0].Cells.Count;
// 在此添加缺少的行
for (int i = 0; i < toLeft; i++)
...{
GridViewRow row = new GridViewRow(-1, -1, DataControlRowType.EmptyDataRow, DataControlRowState.Normal);
for (int j = 0; j < numCols; j++)
...{
TableCell cell = new TableCell();
cell.Text = " ";
row.Cells.Add(cell);
cell.BackColor = System.Drawing.Color.FromArgb(255, 247, 231);
}
GridView1.Controls[0].Controls.AddAt(numCount + 1 + i, row);
}
}
}
int TotalRowCount = 10 ;
// 已经填充的行数
int numCount = 0 ;
protected void GridView1_RowDataBound( object sender, GridViewRowEventArgs e)
... {
if (e.Row.RowType == DataControlRowType.DataRow)
...{
// 计算已经填充的行数
numCount++;
}
if (e.Row.RowType == DataControlRowType.Footer)
...{
// 计算缺少的行数
int toLeft = TotalRowCount - numCount;
// 计算列数
int numCols = GridView1.Rows[0].Cells.Count;
// 在此添加缺少的行
for (int i = 0; i < toLeft; i++)
...{
GridViewRow row = new GridViewRow(-1, -1, DataControlRowType.EmptyDataRow, DataControlRowState.Normal);
for (int j = 0; j < numCols; j++)
...{
TableCell cell = new TableCell();
cell.Text = " ";
row.Cells.Add(cell);
cell.BackColor = System.Drawing.Color.FromArgb(255, 247, 231);
}
GridView1.Controls[0].Controls.AddAt(numCount + 1 + i, row);
}
}
}