Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi Guys,

I have a Gridview and one Add Button out side the gridview.
I am trying to add one new row in gridview and it is being added to the first row of gridview.
But I want to add to the last row.

For example: gridview with paging. 99 records in gridview with pageSize is 10.
I want to add last row in last page of the gridview.
Posted
v3

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[^]
 
Share this answer
 
Comments
CH Guravaiah 20-Jul-12 2:46am    
If it is so it was not a big issue to add it in the very first page but according to client requirment it should be added at the last row of the grid. Could you please give me any idea on such scenerio.
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.
 
Share this answer
 
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.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900