Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 01, 2012 02:56 PM by usman400
Feb 29, 2012 03:06 PM|LINK
I have an ASP.NET Web Forms application. In my application I have a GridView that works smoothly.
Suppose the GridView is placed in myPage.aspx.
If the user follow a specific url, let's say www.mywebsite.com/myPage.aspx?downloadId=n, I want my
GridView to automatically scroll to the one that has the requested download (without deleting the other rows).
I know how to get the downloadId value from the QueryString and that from the
RowDataBound I can check the items (and also retrieve the page index) and compare with the
downloadId and see if it matches, but how can I tell the
GridView to scroll there? Same discussion if I use paging, how can I tell to the GridView to go to a specific page?
Feb 29, 2012 03:28 PM|LINK
GridView1.PageIndex = 2;
Mar 01, 2012 08:41 AM|LINK
Thanks. What about scrolling?
Mar 01, 2012 10:52 AM|LINK
What do u mean by scrolling?
If u r talking about selecting that particular row, then u already have its id, u can first change the page index
and then select that row.
But I beleive, u r talking about vertical scrolling on the page, a workaround coming to mind at the moment is
put a simple label control in item template, and then sue GridView.FindControls method to locate it
U also should look at the following:
Mar 01, 2012 12:42 PM|LINK
Thanks, that is clear but how can I select the row? By using Focus()?
Mar 01, 2012 02:56 PM|LINK
u said, u have the particular id, so after u r changing the page, to go to relevant page, you can iterate through
the particular column and then try with selecting that row, I dont know if we can programmatically select grid view or not
give Google a shot to search: Programatically selecting gridview row