Click here to Skip to main content
16,020,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have put a grid view in div element and set the style of div element is as follows;

style="margin: 0; padding: 0; border-collapse: collapse; width: 350px; height: 500px; overflow: auto; background-color: #FF00FF;"

because of this style div elements shows scrolls if grid view's height is biggest then
div element height.

now what happens when i select any row down the height of div element in grid view it scrolls back to first row

i am not getting how to solve this problem and i want to maintain the state of the grid view even after selecting any row below the height of div element
Posted
Comments
Dholakiya Ankit 13-Aug-13 2:16am    
overflow = 'scroll' may help you gurdeep

1 solution

I assume this is happening on the postback--you select an item, it posts back and therefore rebuilds the page, and when it rebuilds, you lose your position. One thing to try is putting your div in an UpdatePanel, which will give it a partial postback instead of a full refresh--don't remember if this will actually suppress a scroll reset or not. The more common approach, if that fails, is to handle this in client script--you store the scroll position before posting back, and restore it when you return. Here's a walkthrough example: Scroll Gridview while Maintaining Scroll Position[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900