?
Solved

data grid paging - can u set it to a page?

Posted on 2004-05-02
1
Medium Priority
?
309 Views
Last Modified: 2010-04-15
I am using data grid paging on a C# listing program:
"<td borderColor="black"><asp:datagrid id="dg" runat="server" OnPageIndexChanged="dg_PageIndexChanged" AllowPaging="True" PageSize="15" OnItemDataBound="OnItemDataBoundEventHandler" OnItemCreated="OnItemCreatedEventHandler" AutoGenerateColumns="True">
and found that I have to figure out which page I'm on to get the actual line number:
                        int iCtr = e.Item.Controls.Count;
                        int y = dg.Items.Count+(dg.CurrentPageIndex*15);
                        string sID = recordDtl.Rows[y][iCtr].ToString();
Each line in the list (data grid) has a URL attached and when they select it and then later return - it always returns to page 1 no matter what page they were on when they selected from the data grid.
How can you set the page on the data grid to be selected?
Thanks -

0
Comment
Question by:dcass
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 21

Accepted Solution

by:
tovvenki earned 2000 total points
ID: 10974978
Hi,
in the PageIndexChanged event save the current page index in a variable(might be a session variable) and then when you return set the datagrid's CurrentPageIndex property to the saved value
Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) _
Handles DataGrid1.PageIndexChanged
   Session["currentPageIndex"] = e.NewPageIndex;
   DataGrid1.DataBind();
End Sub

DataGrid1.CurrentPageIndex = (int)Session["currentPageIndex"] ;

I hope that this helps you

regards,
venki
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question