//
自动填充的行数
int
numCount
=
0
;
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(
!
Page.IsPostBack)
{
GridView1.DataSource
=
CreateDataSourceByXianhuiMeng();
GridView1.DataBind();
}
}
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);
}
GridView1.Controls[
0
].Controls.AddAt(numCount
+
1
+
i, row);
}
}
}
相关文章
- ASP.net中GridView中增加一行记录并默认显示为编辑状态
- Vue------循环多个ul与li,给li增加点击事件增加class不影响其他的li
- SQLServer在多个表中都增加一个字段的方法
- MySQL多个相同结构的表查询并把结果合并放在一起的语句(union all) MySQL使用select查询时,在查询结果中增加一个字段并指定固定值
- LINUX修改、增加IP的方法,一张网卡绑定多个IP/漂移IP【转】
- 请给Array本地对象增加一个原型方法,它用于删除数组条目中重复的条目(可能有多个),返回值是一个包含被删除的重复条目的新数组。
- 多个mysql增加多个服务
- 使用Reveal.app调试整个项目UI时间,增加LD指令 -Objc引起项目中多个静态库冲突问题
- eclipse中增加多个Tomcat
- GridView动态增加行