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. Calling a JavaScript Function From DataGrid Control

Calling a JavaScript Function From DataGrid Control

Scheduled Pinned Locked Moved ASP.NET
javascriptsaleshelp
8 Posts 4 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.
  • K Offline
    K Offline
    Khan Bangash
    wrote on last edited by
    #1

    I want to call a javaScript Function from DataGrid Control. I hv a DataGrid and there is an LinkButton Button and Customer Name is Displayed on that, I want if some one Click on that Link Button a javaScript Function should b called and also I want to Send ID to that function, How is that possible. My Code is here. ]]>'> Please Help Me, Thanks in Advance.

    C S _ K 4 Replies Last reply
    0
    • K Khan Bangash

      I want to call a javaScript Function from DataGrid Control. I hv a DataGrid and there is an LinkButton Button and Customer Name is Displayed on that, I want if some one Click on that Link Button a javaScript Function should b called and also I want to Send ID to that function, How is that possible. My Code is here. ]]>'> Please Help Me, Thanks in Advance.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      add an onclick to the button. Any attributes that are not recognised by ASP.NET are passed through verbatim to the client.

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      1 Reply Last reply
      0
      • K Khan Bangash

        I want to call a javaScript Function from DataGrid Control. I hv a DataGrid and there is an LinkButton Button and Customer Name is Displayed on that, I want if some one Click on that Link Button a javaScript Function should b called and also I want to Send ID to that function, How is that possible. My Code is here. ]]>'> Please Help Me, Thanks in Advance.

        _ Offline
        _ Offline
        _AK_
        wrote on last edited by
        #3

        You can use the onItemDatabound event of the datagrid to achieve this functionality. In that event just find the link button control and attach the javascript event with it.

        Apurva Kaushal

        1 Reply Last reply
        0
        • K Khan Bangash

          I want to call a javaScript Function from DataGrid Control. I hv a DataGrid and there is an LinkButton Button and Customer Name is Displayed on that, I want if some one Click on that Link Button a javaScript Function should b called and also I want to Send ID to that function, How is that possible. My Code is here. ]]>'> Please Help Me, Thanks in Advance.

          S Offline
          S Offline
          Sherin Iranimose
          wrote on last edited by
          #4

          hi, Did u try with OnClientClick propery of link button by passing 'this' as a parameter?

          **$**herin Iranimose

          K 1 Reply Last reply
          0
          • S Sherin Iranimose

            hi, Did u try with OnClientClick propery of link button by passing 'this' as a parameter?

            **$**herin Iranimose

            K Offline
            K Offline
            Khan Bangash
            wrote on last edited by
            #5

            I applayed all above methods but it s not working.

            S K 2 Replies Last reply
            0
            • K Khan Bangash

              I applayed all above methods but it s not working.

              S Offline
              S Offline
              Sherin Iranimose
              wrote on last edited by
              #6

              coolmindd wrote:

              but it s not working.

              means some error?

              **$**herin Iranimose

              1 Reply Last reply
              0
              • K Khan Bangash

                I applayed all above methods but it s not working.

                K Offline
                K Offline
                Khan Bangash
                wrote on last edited by
                #7

                Now I applayed the following Method and it is working Public Sub itembound(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Dim script As String If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then CType(e.Item.Cells(0).FindControl("name"), LinkButton).Attributes.Add ("onclick", "window.open('/code/customer/addressbook/default.aspx?id=" & dgD.DataKeys.Item(e.Item.ItemIndex) & "','', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=0,width=800,height=600,left = 176,top = 132'); return false;") End If End Sub But I want to Send ID not name to that popup page. If u can see there in query string Name is going. How can I send ID to that page.

                1 Reply Last reply
                0
                • K Khan Bangash

                  I want to call a javaScript Function from DataGrid Control. I hv a DataGrid and there is an LinkButton Button and Customer Name is Displayed on that, I want if some one Click on that Link Button a javaScript Function should b called and also I want to Send ID to that function, How is that possible. My Code is here. ]]>'> Please Help Me, Thanks in Advance.

                  K Offline
                  K Offline
                  Khan Bangash
                  wrote on last edited by
                  #8

                  Now the function is working but when I click first time , it is not working, when I click second time then it works. But I m not able to send ID which is on Cell 0 nd the link button is on cell 1.

                  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