Scroll data grid to the row where edit was clicked
-
Hi All, I am using a datagrid in a ASP.NET page. The data grid is inside a div tag. <div id="divEditProjectRes" style="OVERFLOW: auto; HEIGHT: 150px"> <asp:datagrid id="dgEditResource" runat="server" Width="100%"> There is edit option in each row of the data grid and the user can edit on a few fields. The grid has many records and the user has to scroll down.After scrolling to the record and clicking on edit there is a post back ,and the grid is set back to the top and he again has to scroll back to the row in which now fields are editable. What I want here is that after he clicks on edit the same row must come at the top and the user need not scroll it again. I have used the following code in dgEditResource_EditCommand to set focus to the editable text box in the particular scroll row ,Although it gets the focus but again we need to scroll down . Dim descTB As TextBox descTB = dgEditResource.Items(e.Item.ItemIndex).Cells(2).FindControl("sdate_edit") 'Set the script to focus and select the TextBox RegisterStartupScript("focus", "<script language=""JavaScript""> vbTab & "Form2." & descTB.ClientID & ".focus();" vbCrLf & vbTab & "Form2." & descTB.ClientID & ".select();" & "<" & "/script>") descTB = dgEditResource.Items(e.Item.ItemIndex).Cells(2).FindControl("percent_Edit") If we press tab or space bar the record comes up as focus is already in the text box. But I need that row to scroll up or navigate by itself after edit is clicked. Thanks in advance. Regards, Sakshi :)
-
Hi All, I am using a datagrid in a ASP.NET page. The data grid is inside a div tag. <div id="divEditProjectRes" style="OVERFLOW: auto; HEIGHT: 150px"> <asp:datagrid id="dgEditResource" runat="server" Width="100%"> There is edit option in each row of the data grid and the user can edit on a few fields. The grid has many records and the user has to scroll down.After scrolling to the record and clicking on edit there is a post back ,and the grid is set back to the top and he again has to scroll back to the row in which now fields are editable. What I want here is that after he clicks on edit the same row must come at the top and the user need not scroll it again. I have used the following code in dgEditResource_EditCommand to set focus to the editable text box in the particular scroll row ,Although it gets the focus but again we need to scroll down . Dim descTB As TextBox descTB = dgEditResource.Items(e.Item.ItemIndex).Cells(2).FindControl("sdate_edit") 'Set the script to focus and select the TextBox RegisterStartupScript("focus", "<script language=""JavaScript""> vbTab & "Form2." & descTB.ClientID & ".focus();" vbCrLf & vbTab & "Form2." & descTB.ClientID & ".select();" & "<" & "/script>") descTB = dgEditResource.Items(e.Item.ItemIndex).Cells(2).FindControl("percent_Edit") If we press tab or space bar the record comes up as focus is already in the text box. But I need that row to scroll up or navigate by itself after edit is clicked. Thanks in advance. Regards, Sakshi :)
Please use the
pre
andcode
tags to make your code snippet more readable :-DnolnaH'O eteP - ".sepyt parc rof edoc t'nac ,yhsaw ,ybmap ybman ,ylriw ylrig ,pord dna gard eht morf slanoisseforp eht setarapes tahw s'ti sseug I"