Click here to Skip to main content
11,928,919 members (52,987 online)
Rate this:
Please Sign up or sign in to vote.
See more: Javascript .NET
I have a grid of 100 records.
It is in Div and height limited to 400px, a vertical scroll bar scrolls the whole grid up and down.

the HTML markup is like below...

<div id="dvClinicLookup"  runat="server" style="border: ridge 2px silver; border-radius: 5px;
                                    width: 99%; height: 191px; display: none">
                                    <table border="0">
                                            <td style="width: 26%">
                                                <font face="tahoma" size="2" color="black">Enter Keywords to search</font>
                                                <asp:TextBox ID="txtClinicKeywords" runat="server" Width="50%">
                                                <asp:Button ID="btnFind" runat="server" Text="Find" />
                                            <td colspan="2">
                                                <div id="dv"  runat="server" style="overflow-y: scroll; height: 156px; border: solid 1px silver;">
                                                    <asp:GridView ID="gvClinicLookup1" runat="server" AutoGenerateColumns="false" DataSourceID="dsAllClinics"
                                                        Width="100%" Font-Names="verdana" Font-Size="Smaller" EnableViewState="true">
                                                        <HeaderStyle Height="20px" BackColor="#465c71" ForeColor="White" Font-Bold="true" />
                                                        <rowstyle backcolor="Ivory" font-names="Verdana" />
                                                        <alternatingrowstyle backcolor="White" font-names="Verdana" />
                                                            <asp:BoundField DataField="CLNCode" HeaderText="Clinic Code" ItemStyle-Width="12%"
                                                                HeaderStyle-BorderColor="Black" />
                                                            <asp:BoundField DataField="CLNEtiqaName" HeaderText="Clinic Name" ItemStyle-Width="30%"
                                                                HeaderStyle-BorderColor="Black" />
                                                            <asp:BoundField DataField="address" HeaderText="Clinic Address" ItemStyle-Width="58%"
                                                                HeaderStyle-BorderColor="Black" />
                                                    <asp:SqlDataSource ID="dsAllClinics" runat="server" ConnectionString="<%$ ConnectionStrings:medix_HISDB %>"
                                                        SelectCommand="[spGetAllClinics]" SelectCommandType="StoredProcedure">
                                                            <asp:SessionParameter Name="ClinicName" SessionField="ClinicName" Type="String" />

Now, I want to give a rowindex and gridview should scrolls down to that row.
Javascript assistance is appreciated..

Thanks & Regards
Posted 4-Mar-13 21:06pm
Edited 6-Mar-13 0:34am
Jameel Moideen 5-Mar-13 2:14am
Please share the table structure generated by the Gridview in browser
cyanceenu 5-Mar-13 2:22am
Its has 3 columns col1 number, col2 nvarchar(50), col3 nvarchar(200)

Thanks in anticipation
vimal_2010 6-Mar-13 5:18am
Please provide the html markup of the grid table structure.
cyanceenu 6-Mar-13 5:30am
Hi Vimal, I have updated my question with HTML Markup, please have a look on my question, and thanks for your interest..

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can refer the article[^] to detect the row index with JavaScript.

One challenge on using RowIndex. If you use the below code,
then "this" in this.parent.rowIndex is the window. Not the td element.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web04 | 2.8.151126.1 | Last Updated 9 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100