Wrong datagrid event firing
-
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.
-
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.
-
Make sure that the procedure handles the updatecommand of the datagrid. If still not working do publish the code. Happy Programming, Vimal
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. -
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.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
-
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
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.
-
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.