473,387 Members | 3,033 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,387 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 1826
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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...
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...

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.