Solved

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

Posted on 2004-05-02
1
303 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
1 Comment
 
LVL 21

Accepted Solution

by:
tovvenki earned 500 total points
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now