Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Scroll bar not maintaining its position in ListView (ASP.net)

Scroll bar not maintaining its position in ListView (ASP.net)

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasesysadminalgorithms
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mittalpa
    wrote on last edited by
    #1

    Hi I have a listview inside a DIV which shows the scroll bars. At one time, let's say, 10 rows can be seen. I scroll down and click Edit on 25 row. To my surprise, the scroll goes to the first row (although if I go back to 25th row, the row is in edit mode) My issue, how I can make sure that the scroll bar maintains its position to 25th row after clicking on Edit button? Please advise. Thanks AJ

    <style>
    .StopScroll1{
    Z-INDEX: 20; POSITION: relative;left:-1px; TOP: expression(document.getElementById("divGrid1").scrollTop);
    }
    </style>

    <div id="div1" style="position: relative; width: 100%; width: 700px; height: 200px;
    margin: 0px; padding: 0px; overflow: auto; overflow-x: scroll; overflow-y: scroll">
    <asp:ListView ID="ListView1" runat="server
    OnSorting="Sorting"
    OnItemEditing=" EditList"
    >
    <LayoutTemplate>
    <table class="TableReleative TableFH" style="width: 97.5%;" cellspacing="0" cellpadding="0"
    runat="server" id="tblGrid">
    <tr style="height: 20px;" class="StopScrollTL" runat="server" id="thGrid">
    <th style="text-align: center;">
          
    </th>
    </tr>
    <tr id="itemPlaceholder" runat="server">
    </tr>
    </table>
    </LayoutTemplate>
    <ItemTemplate>
    .....
    </ItemTemplate>

    <EditItemTemplate>
    .....
    </EditItemTemplate>
    </asp:ListView>
    

    </div>

    Follow your goals, Means will follow you ---Gandhi---

    S 1 Reply Last reply
    0
    • M mittalpa

      Hi I have a listview inside a DIV which shows the scroll bars. At one time, let's say, 10 rows can be seen. I scroll down and click Edit on 25 row. To my surprise, the scroll goes to the first row (although if I go back to 25th row, the row is in edit mode) My issue, how I can make sure that the scroll bar maintains its position to 25th row after clicking on Edit button? Please advise. Thanks AJ

      <style>
      .StopScroll1{
      Z-INDEX: 20; POSITION: relative;left:-1px; TOP: expression(document.getElementById("divGrid1").scrollTop);
      }
      </style>

      <div id="div1" style="position: relative; width: 100%; width: 700px; height: 200px;
      margin: 0px; padding: 0px; overflow: auto; overflow-x: scroll; overflow-y: scroll">
      <asp:ListView ID="ListView1" runat="server
      OnSorting="Sorting"
      OnItemEditing=" EditList"
      >
      <LayoutTemplate>
      <table class="TableReleative TableFH" style="width: 97.5%;" cellspacing="0" cellpadding="0"
      runat="server" id="tblGrid">
      <tr style="height: 20px;" class="StopScrollTL" runat="server" id="thGrid">
      <th style="text-align: center;">
            
      </th>
      </tr>
      <tr id="itemPlaceholder" runat="server">
      </tr>
      </table>
      </LayoutTemplate>
      <ItemTemplate>
      .....
      </ItemTemplate>

      <EditItemTemplate>
      .....
      </EditItemTemplate>
      </asp:ListView>
      

      </div>

      Follow your goals, Means will follow you ---Gandhi---

      S Offline
      S Offline
      Sandeep Mewara
      wrote on last edited by
      #2

      Looks like you page gets a postback when you click the edit link. If so, try to set the Page.MaintainScrollPositionOnPostBack Property to true to return the user to the same position in the client browser after postback. (i.e. enabling smart navigation, see if it works!) If not, you will have to use javascripts in order to restore the scrolls. For that, before postback, you need to store the scroll position in a variable and then after page reloads, set it back.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups