473,657 Members | 2,531 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Paging DataGrid

I am having a problem finding out how to page a datagrid.

I have the procedure for moving from page to page as:

private void changePage(obje ct source,
System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)
{
dgCustInfo.Curr entPageIndex = e.NewPageIndex;
--connection information and SELECT statement here not in a separate
procedure--

I have an Edit button in the datagrid to edit the record, but when I click
on it I get an error saying that the pageindex must be >0 <pagecount.

In the editRecord procedure I have the connection information and SELECT
statement to display only the record being edited in the datagrid and
textboxes outside the datagrid that display the data to be edited.

Can someone help me out?

Thanks,
Antonio

Jun 28 '06 #1
3 2239
The correct event should be PageIndexChangi ng in Gridview but
PageIndexChange d in DataGrid:
http://msdn2.microsoft.com/en-us/lib...xchanging.aspx
http://msdn2.microsoft.com/en-us/lib...ed(d=ide).aspx

chanmm

"Antonio" <An*****@discus sions.microsoft .com> wrote in message
news:72******** *************** ***********@mic rosoft.com...
I am having a problem finding out how to page a datagrid.

I have the procedure for moving from page to page as:

private void changePage(obje ct source,
System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)
{
dgCustInfo.Curr entPageIndex = e.NewPageIndex;
--connection information and SELECT statement here not in a separate
procedure--

I have an Edit button in the datagrid to edit the record, but when I click
on it I get an error saying that the pageindex must be >0 <pagecount.

In the editRecord procedure I have the connection information and SELECT
statement to display only the record being edited in the datagrid and
textboxes outside the datagrid that display the data to be edited.

Can someone help me out?

Thanks,
Antonio

Jun 28 '06 #2
When you edit the PageIndex property goes to -1. you can validate that in
the changePage method to don't do paging like:
if(e.NewPageInd ex != -1)
{
}

Regards,

Bela Istok

"Antonio" <An*****@discus sions.microsoft .com> wrote in message
news:72******** *************** ***********@mic rosoft.com...
I am having a problem finding out how to page a datagrid.

I have the procedure for moving from page to page as:

private void changePage(obje ct source,
System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)
{
dgCustInfo.Curr entPageIndex = e.NewPageIndex;
--connection information and SELECT statement here not in a separate
procedure--

I have an Edit button in the datagrid to edit the record, but when I click
on it I get an error saying that the pageindex must be >0 <pagecount.

In the editRecord procedure I have the connection information and SELECT
statement to display only the record being edited in the datagrid and
textboxes outside the datagrid that display the data to be edited.

Can someone help me out?

Thanks,
Antonio


Jun 28 '06 #3
Hi. Thanks for replying. Here is the full procedure I have, so, maybe it can
give more details and help:

private void changePage(obje ct source,
System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)
{
dgCustInfo.Curr entPageIndex = e.NewPageIndex;

SqlConnection conn = new SqlConnection
(ConfigurationS ettings.AppSett ings["SqlConnectionS tring"]);

conn.Open();

SqlCommand dataCommand = new SqlCommand();
dataCommand.Con nection = conn;
dataCommand.Com mandText = "SELECT GEM.customers.n ame AS [Institution
Name], "
+ "GEM.customers. CustomerSince AS [Customer Since], "
+ "GEM.contacts.n ame_first AS [First Name], "
+ "GEM.contacts.n ame_last AS [Last Name], "
+ "GEM.contacts.t itle AS [Contact Title], "
+ "GEM.customers. address_1 AS Address, "
+ "GEM.customers. city AS City, "
+ "GEM.customers. state AS State, "
+ "GEM.customers. province AS Province, "
+ "GEM.customers. zip_code AS [Zip Code], "
+ "GEM.customers. postal_code AS [Postal Code], "
+ "GEM.customers. country AS Country, "
+ "GEM.customers. phone AS Phone, "
+ "GEM.contacts.e mail AS [E-Mail Address], "
+ "GEM.customers. cust_id "
+ "FROM GEM.customers INNER JOIN GEM.config_user names ON "
+ "GEM.customers. cust_id = GEM.config_user names.cust_id INNER JOIN "
+ "GEM.contac ts ON GEM.config_user names.contact_i d =
GEM.contacts.co ntact_id ORDER BY GEM.customers.n ame";

SqlDataAdapter adapter = new SqlDataAdapter( dataCommand);
DataSet ds = new DataSet();
adapter.Fill(ds );
dgCustInfo.Data Source = ds;
dgCustInfo.Data Bind();
conn.Close();
}
"chanmm" wrote:
The correct event should be PageIndexChangi ng in Gridview but
PageIndexChange d in DataGrid:
http://msdn2.microsoft.com/en-us/lib...xchanging.aspx
http://msdn2.microsoft.com/en-us/lib...ed(d=ide).aspx

chanmm

"Antonio" <An*****@discus sions.microsoft .com> wrote in message
news:72******** *************** ***********@mic rosoft.com...
I am having a problem finding out how to page a datagrid.

I have the procedure for moving from page to page as:

private void changePage(obje ct source,
System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)
{
dgCustInfo.Curr entPageIndex = e.NewPageIndex;
--connection information and SELECT statement here not in a separate
procedure--

I have an Edit button in the datagrid to edit the record, but when I click
on it I get an error saying that the pageindex must be >0 <pagecount.

In the editRecord procedure I have the connection information and SELECT
statement to display only the record being edited in the datagrid and
textboxes outside the datagrid that display the data to be edited.

Can someone help me out?

Thanks,
Antonio


Jun 28 '06 #4

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

Similar topics

2
3568
by: RelaxoRy | last post by:
sqlConnection1.Open(); myReader = sqlCommand1.ExecuteReader(); DataGrid1.DataSource = myReader; DataGrid1.DataBind(); myReader.Close(); sqlConnection1.Close(); The Datagrid populates fine. I'm styling it on the HTML page. I configure the DataGrid for paging through the property builder fine. I AllowCustomePaging=true;. The page loads fine but it only shows "1"
2
2244
by: enak | last post by:
I can not get my datagrid to page. I have a datagrid that I can sort 2 of the columns. This works great. I added paging and when I display the dg it shows 5 pages. (I am showing page numbers at the bottom of the dg.) When I click on the pages nothing happens until I get to the last page. Then and only then is the last page displayed. If I go back through the pages the second to last page displayes the first page again.
2
2577
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 to be scrolled down completely to see the page number links. The page number should always be visible outside the scroll bar. Basically I want to create the paging links dynamically and on click of this it should fire PageIndexChanged event.
6
1808
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 fills the temp table again and returns rows 10-19. The temp table is dropped after each call to the SP, so it has to be created and filled every time the user changes page in the datagrid. My question is this: Would it be more efficient to...
2
2216
by: asad | last post by:
Hello friends, i am designing a ASP.NET page where i want to use custom paging bcoz data is too heavy so pls tell me how can i use custom paging in ASP.NET Thanks
2
1855
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 navigation links use JavaScript to jump between pages. I want them to use standard hyperlinks providing the page number in some URL parameter so that I can copy the hyperlink elsewhere.
0
1340
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 populates the data in the Details DataGrid (I'm using Dim Filter As String = CStr(dtgMaster.DataKeys(dtgMaster.SelectedIndex)).Replace("'", "''") to filter btw the Datagrids)
3
1823
by: Pat | last post by:
I have a 2 nested Datagrid. When i select a row in the Master Datagrid i populate the Child databrid using myDataGrid.SelectedIndex value as the filter and setting the DataKeyField. I enabled paging for the MasterDataGrid which works well but when i page to the next set of rows and select a particular ROW(for example SHOW DETAILS) to populated the Child Datagrid after paging to the next page it doesn't work.. it just sends me back to the...
2
1929
by: rn5a | last post by:
In a shopping cart app, a ASPX page retrieves the order details & personal details of a user from a MS-Access database table depending upon the username of the user. The order details of a particular order (like ProductID, Name, Description, Quantity etc.) are displayed in one DataGrid where as the personal details of the buyer corresponding to this order (like Name, E-Mail, Shipping & Billing Address etc.) are displayed in another...
5
3207
by: Donald Adams | last post by:
Hi, I will have both web and win clients and would like to page my data. I could not find out how the datagrid control does it's paging though I did find some sample code that says they do it this way, but I can't see these methods as public. BookmarksDataSetTableAdapters.BookmarksTableAdapter bookTA = new BookmarksDataSetTableAdapters.BookmarksTableAdapter(); BookmarkList1.DataSource = bookTA.GetAllBookmarksWrtUser(
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8740
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8516
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.