Click here to Skip to main content
11,704,044 members (65,854 online)
Rate this: bad
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 20:06pm
Edited 5-Mar-13 23:34pm
Jameel Moideen at 5-Mar-13 2:14am
Please share the table structure generated by the Gridview in browser
cyanceenu at 5-Mar-13 2:22am
Its has 3 columns col1 number, col2 nvarchar(50), col3 nvarchar(200)

Thanks in anticipation
vimal_2010 at 6-Mar-13 5:18am
Please provide the html markup of the grid table structure.
cyanceenu at 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
0 Maciej Los 530
1 OriginalGriff 510
2 Sergey Alexandrovich Kryukov 421
3 Andy Lanng 294
4 F-ES Sitecore 220
0 OriginalGriff 8,744
1 Sergey Alexandrovich Kryukov 7,747
2 CPallini 5,107
3 Maciej Los 4,716
4 Mika Wendelius 3,606

Advertise | Privacy | Mobile
Web04 | 2.8.150819.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