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. Wrong datagrid event firing

Wrong datagrid event firing

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

    Hi, Can anyone shed light on a (strange) problem I am having with a datagrid? The datagrid has a couple of bound columns and an EditCommandColumn. When the edit button is clicked the EditCommand fires correctly, but when the save button is clicked the DeleteCommand is being fired instead of the UpdateCommand. Can you let me know if you have come across this problem as I have searched the web and cannot find a fix for this seemingly straight-forward problem. Thanks. Matt.

    V 1 Reply Last reply
    0
    • M matthewdavies

      Hi, Can anyone shed light on a (strange) problem I am having with a datagrid? The datagrid has a couple of bound columns and an EditCommandColumn. When the edit button is clicked the EditCommand fires correctly, but when the save button is clicked the DeleteCommand is being fired instead of the UpdateCommand. Can you let me know if you have come across this problem as I have searched the web and cannot find a fix for this seemingly straight-forward problem. Thanks. Matt.

      V Offline
      V Offline
      Vimal Raj
      wrote on last edited by
      #2

      Make sure that the procedure handles the updatecommand of the datagrid. If still not working do publish the code. Happy Programming, Vimal

      M 1 Reply Last reply
      0
      • V Vimal Raj

        Make sure that the procedure handles the updatecommand of the datagrid. If still not working do publish the code. Happy Programming, Vimal

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

        Hi Vimal, Thanks for your reply. The sub routine I expect to fire already handles the UpdateCommand of the datagrid. See the code snippet below: Private Sub dgRatePerTerm_UpdateCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgRatePerTerm.UpdateCommand But instead of this line of code firing the DeleteCommand event handler fires instead: Private Sub dgRatePerTerm_DeleteCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgRatePerTerm.DeleteCommand Is there any way that I could have mistakenly changed which events fire when the update button is pressed in the EditCommandColumn?? Thanks again, Matt.

        V 1 Reply Last reply
        0
        • M matthewdavies

          Hi Vimal, Thanks for your reply. The sub routine I expect to fire already handles the UpdateCommand of the datagrid. See the code snippet below: Private Sub dgRatePerTerm_UpdateCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgRatePerTerm.UpdateCommand But instead of this line of code firing the DeleteCommand event handler fires instead: Private Sub dgRatePerTerm_DeleteCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgRatePerTerm.DeleteCommand Is there any way that I could have mistakenly changed which events fire when the update button is pressed in the EditCommandColumn?? Thanks again, Matt.

          V Offline
          V Offline
          Vimal Raj
          wrote on last edited by
          #4

          Hi Matt, I hav never experianced a thing like this. when you said clicking the save button you mean you have set the updateText=Save right? then one more thing if you are not handling the deletecommand(say you are commenting out the deletecommand) then which event is fired? Happy Programming, Vimal

          M 1 Reply Last reply
          0
          • V Vimal Raj

            Hi Matt, I hav never experianced a thing like this. when you said clicking the save button you mean you have set the updateText=Save right? then one more thing if you are not handling the deletecommand(say you are commenting out the deletecommand) then which event is fired? Happy Programming, Vimal

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

            Hi Vimal, Just found the cause of the problem - the data binding function that was being called by the editcommand event was re-setting the edititemindex property of the datagrid to -1! My mistake...:doh: For some reason this causes the datagrid to fire the wrong event when the save button is pressed (I guess it does not know what to do when the update button is clicked but there is no item being edited)... Thanks again for all your suggestions. Matt.

            V 1 Reply Last reply
            0
            • M matthewdavies

              Hi Vimal, Just found the cause of the problem - the data binding function that was being called by the editcommand event was re-setting the edititemindex property of the datagrid to -1! My mistake...:doh: For some reason this causes the datagrid to fire the wrong event when the save button is pressed (I guess it does not know what to do when the update button is clicked but there is no item being edited)... Thanks again for all your suggestions. Matt.

              V Offline
              V Offline
              Vimal Raj
              wrote on last edited by
              #6

              Happy Programming, Vimal

              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