Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Scroll data grid to the row where edit was clicked

Scroll data grid to the row where edit was clicked

Scheduled Pinned Locked Moved Visual Basic
csharpjavascriptcssasp-netsysadmin
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sakshi Smriti
    wrote on last edited by
    #1

    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 :)

    P 1 Reply Last reply
    0
    • S Sakshi Smriti

      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 :)

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      Please use the pre and code tags to make your code snippet more readable :-D

      nolnaH'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"

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups