473,394 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Datagrid & paging

ByB
Hello,

I have a problem in C# with a datagrid i use with paging.

With the paging I can display 10 items in one page.
Those items can be deleted separately.
When i delete one of them, i update the datatable used as datasource
and I redo a DataBind() for the datagrid.

If i have 11 items to display, the 11th item is displayed in the 2nd
page. But if i delete it, the application crashes and I get the
information that CurrentPageIndex is not valid (since I have not 2
pages anymore but 1)

I tried to set the CurrentPageIndex to 1 before I do the databind() but
i get the same error.

Is there a way to correct this ?

thanks.

--
Ceci est une signature automatique de MesNews.
Site : http://www.mesnews.net

Nov 16 '05 #1
2 3909
Hi,

You should make the current page = 0 no 1.

Take into account that this is not the best solution, what happen if you
have 21 instead of 11?
The solution is store the currentpage, delete the items fmor the db and
rebind the grid, check if the currentpage is still a valid page if so set it
or in the other case set it to the max page count possible using PageCount

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"ByB" <em***@email.com> wrote in message
news:mn***********************@email.com...
Hello,

I have a problem in C# with a datagrid i use with paging.

With the paging I can display 10 items in one page.
Those items can be deleted separately.
When i delete one of them, i update the datatable used as datasource and I
redo a DataBind() for the datagrid.

If i have 11 items to display, the 11th item is displayed in the 2nd page.
But if i delete it, the application crashes and I get the information
that CurrentPageIndex is not valid (since I have not 2 pages anymore but
1)

I tried to set the CurrentPageIndex to 1 before I do the databind() but i
get the same error.

Is there a way to correct this ?

thanks.

--
Ceci est une signature automatique de MesNews.
Site : http://www.mesnews.net

Nov 16 '05 #2
ByB
OK, thank you very much for your answer ! :-)

Ignacio Machin ( .NET/ C# MVP ) a émis l'idée suivante :
Hi,

You should make the current page = 0 no 1.

Take into account that this is not the best solution, what happen if you have
21 instead of 11?
The solution is store the currentpage, delete the items fmor the db and
rebind the grid, check if the currentpage is still a valid page if so set it
or in the other case set it to the max page count possible using PageCount

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"ByB" <em***@email.com> wrote in message
news:mn***********************@email.com...
Hello,

I have a problem in C# with a datagrid i use with paging.

With the paging I can display 10 items in one page.
Those items can be deleted separately.
When i delete one of them, i update the datatable used as datasource and I
redo a DataBind() for the datagrid.

If i have 11 items to display, the 11th item is displayed in the 2nd page.
But if i delete it, the application crashes and I get the information that
CurrentPageIndex is not valid (since I have not 2 pages anymore but 1)

I tried to set the CurrentPageIndex to 1 before I do the databind() but i
get the same error.

Is there a way to correct this ?

thanks.

-- Ceci est une signature automatique de MesNews.
Site : http://www.mesnews.net


--
Ceci est une signature automatique de MesNews.
Site : http://www.mesnews.net

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jos Walrave | last post by:
I want to create an ASP.NET web application using C#. Purpose of the web application is access to a MS SQL Server database. Some of our customers are using large databases, so the application...
2
by: Ben | last post by:
Hi, I'd like to have a datagrid that has a dropdownlist in the pager control for setting the page size. I can get the control into the pager inside the datagrid itemcreated event by checking for...
2
by: ddaniel | last post by:
I have read many posts and seen many papers on the different techniques for sort and filtering datagrids. Many do re-queries against the dB ala Fritz Onion. I am trying to leverage the Dataview....
2
by: RJN | last post by:
Hi Sorry for posting again. I have a datagrid which is put inside a div tag to make it scrollable. I need to page the datagrid. The page numbers appear at the bottom of the datagrid and has...
6
by: Shawn | last post by:
Hi. I already have a datagrid where I'm using paging. I have a stored procedure that fills a temp table with 200-500 rows and then sends back 10 records at the time. When I go to page 2 the SP...
2
by: Axel Dahmen | last post by:
Hi, I'm using a DataGrid control to show a table's content with paging. For navigation through the pages I'm using the DataGrid's intrinsic navigation section. My problem: The DataGrid...
2
by: pmanno | last post by:
If I have a page with a DataGrid that is bound to a DataTable that is populated by a query to a database and I want to enable sorting and paging, do I have to add the DataTable to the cache or will...
5
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go...
0
by: Pat | last post by:
I have 3 Datagrid nested. Master Details Child The master has paging (And i'm using the paging inbuilt in the Datagrid) in the Master DataGrid you select a linkbutton(using commandname) and it...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.