473,322 Members | 1,345 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,322 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 1822
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.