Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Scroll down to selected item in gridview using javascript

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.14k
    Comment on it

    The blog is related to move the position of scroll according to the selected item using javascript:- Consider the following example:- Let's say you have a gridview control and a dropdown above that. If you select any item from dropdown the gridview should move the scroll position according to selected item and display the item inside the div.

    Here i am writing down the snapshot of code:-

    <asp:dropdownlist id="drpPanels" runat="server" datasourceid="PanelsDataSource" datatextfield="SubCategoryName" datavaluefield="PanelID" onchange="MoveScrollPosition(this);">
    </asp:dropdownlist>
    <div id="outerholder" style="float: left">
         <asp:gridview id="Gridview1" runat="server">
         </asp:gridview>
    </div>
    
    
       <script type="text/javascript">
        function MoveScrollPosition(object) { //object here is object of dropdownlist
            var container = document.getElementById("outerholder");
            var Cpanel;
            if (object.selectedIndex < 10) {
                Cpanel = document.getElementById("ctl00&#95;ContentPlaceHolder1&#95;lstPanels&#95;ctl0" + object.selectedIndex + "&#95;pnlMain");
            }
            else {
                Cpanel = document.getElementById("ctl00&#95;ContentPlaceHolder1&#95;lstPanels&#95;ctl" + object.selectedIndex + "&#95;pnlMain");
            }
            //alert(Cpanel.offsetTop * object.selectedIndex);
            container.scrollTop = Cpanel.offsetTop ;
            //Object.scrollIntoView(false);
        }
    </script>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: