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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Passing Parameters in buttonclick event in gridview

Passing Parameters in buttonclick event in gridview

Scheduled Pinned Locked Moved ASP.NET
regexhelptutorial
4 Posts 3 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.
  • N Offline
    N Offline
    needhi_p
    wrote on last edited by
    #1

    Hi.. I want to pass arguments in buttonclick event in gridivew from aspx page... ]]>'/> this image button is in gridview's ItemTemplate And i have a function like this in code behind.. protected void addtocrt_Click(string str) { Response.Write(str); } But it gives me error... 1) The best overloaded method match for 'Right.addtocrt_Click(string)' has some invalid arguments 2) cannot convert from 'object' to 'string' How to solve this.. Plz give me some solution..

    K S 2 Replies Last reply
    0
    • N needhi_p

      Hi.. I want to pass arguments in buttonclick event in gridivew from aspx page... ]]>'/> this image button is in gridview's ItemTemplate And i have a function like this in code behind.. protected void addtocrt_Click(string str) { Response.Write(str); } But it gives me error... 1) The best overloaded method match for 'Right.addtocrt_Click(string)' has some invalid arguments 2) cannot convert from 'object' to 'string' How to solve this.. Plz give me some solution..

      K Offline
      K Offline
      Krazy Programmer
      wrote on last edited by
      #2

      sorry i may be wrong ..."TYPE CASTING"

      Dont Get Paid for the Hours you worked, Get Paid for the Work You Have Done in an Hour.

      1 Reply Last reply
      0
      • N needhi_p

        Hi.. I want to pass arguments in buttonclick event in gridivew from aspx page... ]]>'/> this image button is in gridview's ItemTemplate And i have a function like this in code behind.. protected void addtocrt_Click(string str) { Response.Write(str); } But it gives me error... 1) The best overloaded method match for 'Right.addtocrt_Click(string)' has some invalid arguments 2) cannot convert from 'object' to 'string' How to solve this.. Plz give me some solution..

        S Offline
        S Offline
        samMaster
        wrote on last edited by
        #3

        Hi Test this: addtocrt_Click(Eval("Prod_ID").ToString()) You can pass the parameters in this way too: CommandArgument='<%# Eval("Prod_ID") %>' onclick="addtocrt_Click"> protected void addtocrt_Click(object sender, EventArgs e) { try { ImageButton imgbtn = sender as ImageButton; Response.Write(imgbtn.CommandArgument); } catch (Exception ex) { throw; } }

        N 1 Reply Last reply
        0
        • S samMaster

          Hi Test this: addtocrt_Click(Eval("Prod_ID").ToString()) You can pass the parameters in this way too: CommandArgument='<%# Eval("Prod_ID") %>' onclick="addtocrt_Click"> protected void addtocrt_Click(object sender, EventArgs e) { try { ImageButton imgbtn = sender as ImageButton; Response.Write(imgbtn.CommandArgument); } catch (Exception ex) { throw; } }

          N Offline
          N Offline
          needhi_p
          wrote on last edited by
          #4

          Hey thanx... It worked for me...

          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