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. Buttons in DataGrid not working

Buttons in DataGrid not working

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

    Hi, I am creating a datagrid with a column of buttons. I thought I set it up so that when a button is pushed the DataGrid1_ItemCommand is called, but for some reason it is not working. Here is my html code: And here is my server code: public void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { Label2.Text = "asdfasedfasdf"; } Similar code works on other pages. Am I missing something? Thanks, RC

    M 1 Reply Last reply
    0
    • C chubbysilk

      Hi, I am creating a datagrid with a column of buttons. I thought I set it up so that when a button is pushed the DataGrid1_ItemCommand is called, but for some reason it is not working. Here is my html code: And here is my server code: public void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { Label2.Text = "asdfasedfasdf"; } Similar code works on other pages. Am I missing something? Thanks, RC

      M Offline
      M Offline
      Marcie Jones
      wrote on last edited by
      #2

      Hi RC, If you're using VS.NET and CodeBehind, make sure you still have the following in your Initialize Component code: this.DataGrid1.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_ItemCommand); Datagrid Girl http://www.datagridgirl.com http://www.codeproject.com

      C 1 Reply Last reply
      0
      • M Marcie Jones

        Hi RC, If you're using VS.NET and CodeBehind, make sure you still have the following in your Initialize Component code: this.DataGrid1.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_ItemCommand); Datagrid Girl http://www.datagridgirl.com http://www.codeproject.com

        C Offline
        C Offline
        chubbysilk
        wrote on last edited by
        #3

        That code is already in the InitializeComponent() method. But it still doesn't work.

        M 1 Reply Last reply
        0
        • C chubbysilk

          That code is already in the InitializeComponent() method. But it still doesn't work.

          M Offline
          M Offline
          Marcie Jones
          wrote on last edited by
          #4

          The other thing to check is whether you're re-Databinding the grid in the Page Load event without checking IsPostBack, that would prevent your other events from firing. Datagrid Girl http://www.codeproject.com

          C 1 Reply Last reply
          0
          • M Marcie Jones

            The other thing to check is whether you're re-Databinding the grid in the Page Load event without checking IsPostBack, that would prevent your other events from firing. Datagrid Girl http://www.codeproject.com

            C Offline
            C Offline
            chubbysilk
            wrote on last edited by
            #5

            That was it. I was re-binding the datagrid in the Page_Load. Thanks for your help!! RC

            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