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. Web Development
  3. ASP.NET
  4. assign javascript to linkbutton in datagrid

assign javascript to linkbutton in datagrid

Scheduled Pinned Locked Moved ASP.NET
javascripttutorialquestion
3 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.
  • J Offline
    J Offline
    jszpila
    wrote on last edited by
    #1

    Hello everyone, I have a datagrid in with there is a linkbutton that uses the ItemCommand. When this is clicked, I would like to open a new window and pass the page in the new window the datakeyfield value of the row in which the button was clicked. I've done similar things before with just a link button by itself, along the lines of: lnkButton.Attributes("onClick") = "window.open('mypage.aspx?RowID=" & intRowID & ")" But I'm having a hard time figuring out how to adapt that to work from within a datagrid. Any pointers would be greatly appreciated. Thanks in advance! ------------------- abort, retry, fail?

    P 1 Reply Last reply
    0
    • J jszpila

      Hello everyone, I have a datagrid in with there is a linkbutton that uses the ItemCommand. When this is clicked, I would like to open a new window and pass the page in the new window the datakeyfield value of the row in which the button was clicked. I've done similar things before with just a link button by itself, along the lines of: lnkButton.Attributes("onClick") = "window.open('mypage.aspx?RowID=" & intRowID & ")" But I'm having a hard time figuring out how to adapt that to work from within a datagrid. Any pointers would be greatly appreciated. Thanks in advance! ------------------- abort, retry, fail?

      P Offline
      P Offline
      Paddy Boyd
      wrote on last edited by
      #2

      In the datagrid onRowDatabound event, you can use code like the following to find the linkbutton in that row, and then your code above should work the same: Dim btnLink as LinkButton btnLink = CType(e.Item.FindControl("lnkId"), LinkButton) 'Your code here

      J 1 Reply Last reply
      0
      • P Paddy Boyd

        In the datagrid onRowDatabound event, you can use code like the following to find the linkbutton in that row, and then your code above should work the same: Dim btnLink as LinkButton btnLink = CType(e.Item.FindControl("lnkId"), LinkButton) 'Your code here

        J Offline
        J Offline
        jszpila
        wrote on last edited by
        #3

        D'oh, that makes sense! Thanks! ------------------- abort, retry, fail?

        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