如何使用asp.Net在Gridview的ItemTemplate中使用分页添加新行 [英] How to add a new row in ItemTemplate of Gridview with paging using asp.Net

查看:232
本文介绍了如何使用asp.Net在Gridview的ItemTemplate中使用分页添加新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个Gridview和一个在网格视图旁边的添加按钮.
我正在尝试在gridview中添加一个新行,并将其添加到gridview的第一行中.
但我想添加到最后一行.

例如:带有分页的gridview.在gridview中的99条记录的pageSize为10.
我想在gridview的最后一页中添加最后一行.

解决方案

gridview中99条记录的pageSize为10,我想在最后一页中添加最后一行gridview的.
1.如果您在第1页上,请尝试添加一些应该可见的内容,而不是第10页上的任何地方
2.您的添加设计应以一种实现上述第1点的方式来实现,并且不会混淆用户的编辑项目

看看这些文章,看看它是如何实现的:
GridView一目了然 [在GridView中就地编辑 [在ASP.NET 2.0中可编辑GridView [ ^ ]

您好,
您在这里使用自定义控件还是用户控件?
如果没有

addButton单击
{
datagridID.Add.Rows(1);
}
请参阅更多内容
如何在按钮上动态向GridView添加行单击事件 [ 解决方案

99 records in gridview with pageSize is 10 , I want add last row in last page of the gridview .
1. If you are on page 1, and try to add something it should be visible and not somewhere on page 10
2. Your add design should be in a way implemented that point 1 above is considered and it does not confused user from edit items

Have a look at these articles to see on how it is implemented:
GridView all in one[^]
Inplace Edit in GridView[^]
Editable GridView in ASP.NET 2.0[^]


Hi ,
here r u using custom control or usercontrol?
if not

addButton Click
{
datagridID.Add.Rows(1);
}
please see for more
How to Add a Row to GridView Dynamically on Button Click Event[^]

i think it would be useful to you.


First we can find out the Number of rows in Gridview and also pageSize of the Gridview.


Calculating of both Like :

dim rowCount as integer = Griview1.tables(0).rows.count -1
dim totalCount as integer=convert.toint32(convert.toDecimal(Math.Floor(rowCount/Griview1.pagaSize)))+1

GridView1.DataSource=DS
Gridview1.PageIndext= totalCount
Gridview1.DataBind()

when we click on the Add Button .Last row can be added in gridview.


这篇关于如何使用asp.Net在Gridview的ItemTemplate中使用分页添加新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆