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. How to get the command name of a control

How to get the command name of a control

Scheduled Pinned Locked Moved ASP.NET
helptutorialquestion
5 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.
  • M Offline
    M Offline
    momo007
    wrote on last edited by
    #1

    hi everybody, it seems that i have a biiig problem, and i'm counting on you to resolve it... pls :) well, i want to get the name of a button's command in a datagrid. here is the code that i've made: void DataGrid1_ItemCommand(object source, DataGridCommandEventArgs e) { if(e.CommandName=="Editer") { int id; LinkButton tb_id=(LinkButton)e.Item.Cells[6].Controls[0]; id=Convert.ToInt32(tb_id.Text); Response.Redirect("FicheModulesTech.aspx?id_cours="+id); } } the command name is "Editer", and it doesn't work!!! anyone can help??? thanks

    M O 2 Replies Last reply
    0
    • M momo007

      hi everybody, it seems that i have a biiig problem, and i'm counting on you to resolve it... pls :) well, i want to get the name of a button's command in a datagrid. here is the code that i've made: void DataGrid1_ItemCommand(object source, DataGridCommandEventArgs e) { if(e.CommandName=="Editer") { int id; LinkButton tb_id=(LinkButton)e.Item.Cells[6].Controls[0]; id=Convert.ToInt32(tb_id.Text); Response.Redirect("FicheModulesTech.aspx?id_cours="+id); } } the command name is "Editer", and it doesn't work!!! anyone can help??? thanks

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, In most cases, the words "it doesn't work" do not help people much in figuring out the cause of an issue. Do you mean the execution does not get in the body of the if statement or you cannot access the id value? Is the Editer is the CommandName of the LinkButton? Here, from what your sample code I guess that you want to get the id_cours value and redirect to another way, if so you might to try the HyperLinkColumn or the HyperLink control instead of the LinkButton.

      1 Reply Last reply
      0
      • M momo007

        hi everybody, it seems that i have a biiig problem, and i'm counting on you to resolve it... pls :) well, i want to get the name of a button's command in a datagrid. here is the code that i've made: void DataGrid1_ItemCommand(object source, DataGridCommandEventArgs e) { if(e.CommandName=="Editer") { int id; LinkButton tb_id=(LinkButton)e.Item.Cells[6].Controls[0]; id=Convert.ToInt32(tb_id.Text); Response.Redirect("FicheModulesTech.aspx?id_cours="+id); } } the command name is "Editer", and it doesn't work!!! anyone can help??? thanks

        O Offline
        O Offline
        OmegaCD
        wrote on last edited by
        #3

        Hi, Use the following code: LinkButton lb = (LinkButton)DataGrid1.Items[e.Item.ItemIndex].Controls[2].Controls[0]; I posted some tutorials on how to customize the DataGrid control at www.KYNOU.com. There is also a chat room there and I try to be there as long as I can. If you have any question please stop by and I will be glad to try to help you. :)

        M 1 Reply Last reply
        0
        • O OmegaCD

          Hi, Use the following code: LinkButton lb = (LinkButton)DataGrid1.Items[e.Item.ItemIndex].Controls[2].Controls[0]; I posted some tutorials on how to customize the DataGrid control at www.KYNOU.com. There is also a chat room there and I try to be there as long as I can. If you have any question please stop by and I will be glad to try to help you. :)

          M Offline
          M Offline
          momo007
          wrote on last edited by
          #4

          thanxs for the reply i'll try this code you gave me. thanks again :-D

          M 1 Reply Last reply
          0
          • M momo007

            thanxs for the reply i'll try this code you gave me. thanks again :-D

            M Offline
            M Offline
            momo007
            wrote on last edited by
            #5

            hello again, well i'm working with dotnet 2003. i can't find a way to create an hyperlink button or a checkbox. do you have an idea please thanks

            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