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. DataGrid Buttons

DataGrid Buttons

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

    Hi, Im using a DataGrid to display some info from the DB. Instead of the standard edit column i created a template column, with a button in it. If i use a Linkbutton it all works fine. However if i use a standard button nothing happens. Ive given the button a CommandName of Edit, and under the ItemCommand ive got: private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { //performs relevant action for button if (e.CommandName == "Edit") { DataGrid1.EditItemIndex=e.Item.ItemIndex; DataGrid1.DataBind(); }Label15.Text="Edit"; } But nothing happens. Ive even put in a test bit of code to indicate via a label if the DataGrid1_ItemCommand is called. But it doesnt work, so obviously its not being activated. Any ideas why??? Ive put DataGrid1_ItemCommand in the appropriate DataGrid properties option. I need help! Thanks!!!

    A 1 Reply Last reply
    0
    • M munklefish

      Hi, Im using a DataGrid to display some info from the DB. Instead of the standard edit column i created a template column, with a button in it. If i use a Linkbutton it all works fine. However if i use a standard button nothing happens. Ive given the button a CommandName of Edit, and under the ItemCommand ive got: private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { //performs relevant action for button if (e.CommandName == "Edit") { DataGrid1.EditItemIndex=e.Item.ItemIndex; DataGrid1.DataBind(); }Label15.Text="Edit"; } But nothing happens. Ive even put in a test bit of code to indicate via a label if the DataGrid1_ItemCommand is called. But it doesnt work, so obviously its not being activated. Any ideas why??? Ive put DataGrid1_ItemCommand in the appropriate DataGrid properties option. I need help! Thanks!!!

      A Offline
      A Offline
      AnantAwadhut
      wrote on last edited by
      #2

      Try this, you take a button column and then turn it the template column. This will be done.

      M 1 Reply Last reply
      0
      • A AnantAwadhut

        Try this, you take a button column and then turn it the template column. This will be done.

        M Offline
        M Offline
        munklefish
        wrote on last edited by
        #3

        Ok, i forgot to put the binding code inside !PostBack so it was just reloading the data, and not appearing to change to edit mode. However, now my problem is that when i click to enter 'edit' mode the all the Data / DataGrid disappears except for the Header. Why is this? I even tried using a DataList instead and this does the same. Im obviously missing something. HELPPPPPPPPPPPPPPPPPPP!!!!

        E 1 Reply Last reply
        0
        • M munklefish

          Ok, i forgot to put the binding code inside !PostBack so it was just reloading the data, and not appearing to change to edit mode. However, now my problem is that when i click to enter 'edit' mode the all the Data / DataGrid disappears except for the Header. Why is this? I even tried using a DataList instead and this does the same. Im obviously missing something. HELPPPPPPPPPPPPPPPPPPP!!!!

          E Offline
          E Offline
          E L Golpe
          wrote on last edited by
          #4

          Check the editable property of your columns. It should be set to allow editing to be visible. Practice sesquipedalianism! ;)

          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