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

DataGrid Paging

I'm trying to use the automatic paging for the data grid.
When I click previous or next I get no errors, but the
first page is always displayed.

Below is the code. Any help would be appreciated.
HTML:
<asp:datagrid id="dgOwnerList" runat="server"
AllowPaging="True" PageSize="3"></asp:datagrid>
Code Behind:
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
InitializeData();
}

private void InitializeData()
{
worknum = Int32.Parse(Request.QueryString
["worknum"]);
object[] row;

// Create a data table to bind to the data grid
control.
dt = new DataTable("OwnerList");

dt.Columns.Add("LastName");
dt.Columns.Add("FirstName");
dt.Columns.Add("MI");
dt.Columns.Add("AddressText");
dt.Columns.Add("Book");
dt.Columns.Add("Page");
dt.Columns.Add("City");
dt.Columns.Add("State");

OwnerInfo[] owners = OwnerProcess.GetOwners
(worknum);

foreach(OwnerInfo o in owners)
{
row = new object[]
{
o.LastName, o.FirstName,
o.MiddleInitial,
o.Street, o.Book, o.Page,
o.Town,
o.StateAbbr
};
dt.Rows.Add(row);
}

if (dt.Rows.Count > 0)
{
dgOwnerList.DataSource = dt;
dgOwnerList.DataBind();
}

}

Nov 15 '05 #1
1 3288
Would the new MSDN article help by any chance?

http://msdn.microsoft.com/asp.net/de...lesortable.asp

"Mike O" <mi***@yahoo.com> wrote in message
news:01****************************@phx.gbl...
I'm trying to use the automatic paging for the data grid.
When I click previous or next I get no errors, but the
first page is always displayed.

Below is the code. Any help would be appreciated.
HTML:
<asp:datagrid id="dgOwnerList" runat="server"
AllowPaging="True" PageSize="3"></asp:datagrid>
Code Behind:
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
InitializeData();
}

private void InitializeData()
{
worknum = Int32.Parse(Request.QueryString
["worknum"]);
object[] row;

// Create a data table to bind to the data grid
control.
dt = new DataTable("OwnerList");

dt.Columns.Add("LastName");
dt.Columns.Add("FirstName");
dt.Columns.Add("MI");
dt.Columns.Add("AddressText");
dt.Columns.Add("Book");
dt.Columns.Add("Page");
dt.Columns.Add("City");
dt.Columns.Add("State");

OwnerInfo[] owners = OwnerProcess.GetOwners
(worknum);

foreach(OwnerInfo o in owners)
{
row = new object[]
{
o.LastName, o.FirstName,
o.MiddleInitial,
o.Street, o.Book, o.Page,
o.Town,
o.StateAbbr
};
dt.Rows.Add(row);
}

if (dt.Rows.Count > 0)
{
dgOwnerList.DataSource = dt;
dgOwnerList.DataBind();
}

}

Nov 15 '05 #2

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

Similar topics

2
by: RelaxoRy | last post by:
sqlConnection1.Open(); myReader = sqlCommand1.ExecuteReader(); DataGrid1.DataSource = myReader; DataGrid1.DataBind(); myReader.Close(); sqlConnection1.Close(); The Datagrid populates fine. ...
3
by: Joseph D. DeJohn | last post by:
I am trying to get pagination working on a datagrid. Can anyone point me to a resource for help on this? I'm not sure if custom paging is the best option or not.
2
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...
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...
5
by: quanga | last post by:
Hi- I have a datagrid that in some cases can be several thousand rows in length. What I'd like it to do is have the data pushed to the browser after every, say, 100 rows or so. Kind of a...
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...
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...
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...
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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....

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.