473,407 Members | 2,306 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,407 software developers and data experts.

Paging of a data grid

I've added a data grid to my page but the automatic paging feature doesn't
seem to be working.

The code I have on page load is as follows. Can anyone suggest why this
isn't working?

SqlDataAdapter adSales;
SqlConnection con = new
SqlConnection(System.Configuration.ConfigurationSe ttings.AppSettings.Get("Co
nnectionString"));
adSales = new SqlDataAdapter("SELECT * FROM AllOrdersOverview ORDER BY
OrderDate ASC", con);
DataSet dsSales = new DataSet();
adSales.Fill(dsSales,"Sales");
grdSales.DataSource = dsSales;
grdSales.DataBind();
Page.DataBind();
Nov 18 '05 #1
3 1832
Hi, Andrew

What do you get? An error or an unpaged data grid?

Bin Song, MCP

----- Andrew Banks wrote: -----

I've added a data grid to my page but the automatic paging feature doesn't
seem to be working.

The code I have on page load is as follows. Can anyone suggest why this
isn't working?

SqlDataAdapter adSales;
SqlConnection con = new
SqlConnection(System.Configuration.ConfigurationSe ttings.AppSettings.Get("Co
nnectionString"));
adSales = new SqlDataAdapter("SELECT * FROM AllOrdersOverview ORDER BY
OrderDate ASC", con);
DataSet dsSales = new DataSet();
adSales.Fill(dsSales,"Sales");
grdSales.DataSource = dsSales;
grdSales.DataBind();
Page.DataBind();

Nov 18 '05 #2
like bill said:

Private Sub dataGrid2_PageIndexChanged(ByVal source As System.Object, ByVal
e As System.Web.UI.WebControls.DataGridPageChangedEvent Args) Handles
DataGrid2.PageIndexChanged

DataGrid2.CurrentPageIndex = e.NewPageIndex
getData()

End Sub

*** When you do this, your program will throw an error when you delete the
last item on a datagrid page. Therefore when you load your datagrid
you must have the following: ***

Try 'need this try/catch when datagrid allows paging and the last item of a
"page" is deleted
DataGrid2.DataBind()
Catch
DataGrid2.CurrentPageIndex = DataGrid2.PageCount - 1
DataGrid2.DataBind()
End Try

"Andrew Banks" <ba****@nojunkblueyonder.co.uk> wrote in message
news:cW*******************@news-text.cableinet.net...
I've added a data grid to my page but the automatic paging feature doesn't
seem to be working.

The code I have on page load is as follows. Can anyone suggest why this
isn't working?

SqlDataAdapter adSales;
SqlConnection con = new
SqlConnection(System.Configuration.ConfigurationSe ttings.AppSettings.Get("Co nnectionString"));
adSales = new SqlDataAdapter("SELECT * FROM AllOrdersOverview ORDER BY
OrderDate ASC", con);
DataSet dsSales = new DataSet();
adSales.Fill(dsSales,"Sales");
grdSales.DataSource = dsSales;
grdSales.DataBind();
Page.DataBind();

Nov 18 '05 #3
like bill said:

Private Sub dataGrid2_PageIndexChanged(ByVal source As System.Object, ByVal
e As System.Web.UI.WebControls.DataGridPageChangedEvent Args) Handles
DataGrid2.PageIndexChanged

DataGrid2.CurrentPageIndex = e.NewPageIndex
getData()

End Sub

*** When you do this, your program will throw an error when you delete the
last item on a datagrid page. Therefore when you load your datagrid
you must have the following: ***

Try 'need this try/catch when datagrid allows paging and the last item of a
"page" is deleted
DataGrid2.DataBind()
Catch
DataGrid2.CurrentPageIndex = DataGrid2.PageCount - 1
DataGrid2.DataBind()
End Try

"Andrew Banks" <ba****@nojunkblueyonder.co.uk> wrote in message
news:cW*******************@news-text.cableinet.net...
I've added a data grid to my page but the automatic paging feature doesn't
seem to be working.

The code I have on page load is as follows. Can anyone suggest why this
isn't working?

SqlDataAdapter adSales;
SqlConnection con = new
SqlConnection(System.Configuration.ConfigurationSe ttings.AppSettings.Get("Co nnectionString"));
adSales = new SqlDataAdapter("SELECT * FROM AllOrdersOverview ORDER BY
OrderDate ASC", con);
DataSet dsSales = new DataSet();
adSales.Fill(dsSales,"Sales");
grdSales.DataSource = dsSales;
grdSales.DataBind();
Page.DataBind();

Nov 18 '05 #4

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

Similar topics

2
by: Luis Esteban Valencia | last post by:
I have a data grid control with a templated checkbox column residing in a asp.net user control. The checkbox boolean state determines if the item is later added or removed from another database...
2
by: Daniel Walzenbach | last post by:
Hi, I have a question regarding the DataGrid control. If paging is enabled the grid binds the data, sets the paging on the top/bottom (or however it is set up) and throws away unnecessary...
2
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
6
by: Dee | last post by:
Hi The paging numbers of my DataGrid dont actually page. What can be the cause? Everyting else seems to work. Thanks Dee
3
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...
4
by: news.microsoft.com | last post by:
I've looked in the help and at each of the properties for the grid view, but can't seem to find what I need. I have allowpaging set to true for my gridview and when the page loads I go and fetch...
3
by: nyhetsgrupper | last post by:
Hi everyone, In a datagrid the entire data is read but only the page you want is displayed to the user when you enable paging. Does the Gridview control works in the same way? So if you have...
7
by: =?Utf-8?B?SmVmZiBCZWVt?= | last post by:
The default paging behavior of the gridview doesn't work well with very large sets of data which means we have to implement some sort of custom paging. The examples I have seen (4guysfromrolla,...
1
by: =?Utf-8?B?TG95b2xhIHN0YWxpbg==?= | last post by:
Hi, I am using ASP.Net 2.0 version and Windows'XP OS. I am useing the Grid view control to display the user details along with the paging concept provided by the grid view control. When i...
2
by: Ilyas | last post by:
Hi all I need to implmenet paging across different tables. The tables all have a different name eg Data01, data02 data03 etc, however they are columns which are common to each table, but each...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.