Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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">
                                        <tr>
                                            <td style="width: 26%">
                                                <font face="tahoma" size="2" color="black">Enter Keywords to search</font>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtClinicKeywords" runat="server" Width="50%">
                                                <asp:Button ID="btnFind" runat="server" Text="Find" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <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" />
                                                        <columns>
                                                            <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" />
                                                        </columns>
                                                    
                                                    <asp:SqlDataSource ID="dsAllClinics" runat="server" ConnectionString="<%$ ConnectionStrings:medix_HISDB %>"
                                                        SelectCommand="[spGetAllClinics]" SelectCommandType="StoredProcedure">
                                                        <SelectParameters>
                                                            <asp:SessionParameter Name="ClinicName" SessionField="ClinicName" Type="String" />
                                                        </SelectParameters>
                                                    
                                                
                                            </td>
                                        </tr>
                                    </table>





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

Thanks & Regards
Sri
Posted
Updated 5-Mar-13 23:34pm
v5
Comments
Jameel VM 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

You can refer the article http://www.maratz.com/blog/archives/2005/05/18/detect-table-row-index-with-javascript/[^] to detect the row index with JavaScript.

One challenge on using RowIndex. If you use the below code,
JavaScript
this.parent.rowIndex 

then "this" in this.parent.rowIndex is the window. Not the td element.
 
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