Solved

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

Posted on 2004-05-02
1
305 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
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

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…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

832 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