Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-05-02
1
Medium Priority
?
311 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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

610 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