Asp net gridview rowupdating firing twice

Grid View Edit Event Args) Handles grd Combinations.

New Edit Index Fill Combinations() End Sub Protected Sub grd Combinations_Cancel Row Editing(By Val sender As Object, By Val e As System.

(also I used a static counter to see how many times the event gets fired when clicking on the Grid View delete button, which was also confirmed it that it's counting 2 per each click). please help ok, just in case anyone else is facing events getting triggered twice (for any reason), and getting the infamous "Deleted row information cannot be accessed through the row." exception, I wrote a method that prevents the duplication (unorthodox but it works).

However, now that the event triggering twice is solve. Seconds For what it's worth my solution/dirty hack ' Declare a global boolean Public exit Sub As Boolean = False Sub Dothis Once(blah, blah) If exit Sub = True Then Exit Sub End If ' Do some coding/DB work or something ' code has ran so set boolean to true Here's a link to some information regarding Microsoft's awareness of this bug and a fairly good workaround that doesn't involve hacky flags: View_commands_ _Auto Event Wire Up Thanks for reporting the issue.

Note: the example above shows how you can pass a value of another column on the same row that you wish to delete (ex: item_id is a field of another column in the same row) to your event handler that can help you delete a record from the database. NET in case anyone needs it: Private Function Ok2Delete(By Val p Row As String) As Boolean If Session("Row Index") Is Nothing Or Else _ (CInt(Session("Rowindex")) = p Row And Also Date Time. This is a known issue and we areinvestigating fixing this in the next service pack.

For the time beingyou could use the following work around.

w=800" src="https://taditdash.files.wordpress.com/2014/06/debugger-inside-gridview-rowupdating-event.png? w=800&h=359" alt="Debugger Inside Grid View Row Updating Event" width="800" height="359" class="size-full wp-image-328" srcset="https://taditdash.files.wordpress.com/2014/06/debugger-inside-gridview-rowupdating-event.png? w=230" src="https://taditdash.files.wordpress.com/2014/06/gridview-on-browser.png? w=800" alt="Grid View on Browser" class="size-full wp-image-335" srcset="https://taditdash.files.wordpress.com/2014/06/230w, https://taditdash.files.wordpress.com/2014/06/gridview-on-browser.png? w=416" src="https://taditdash.files.wordpress.com/2014/06/gridview-cell-showing-updated-value.png? w=800" alt="Grid View Cell Showing Updated Value" class="size-full wp-image-331" srcset="https://taditdash.files.wordpress.com/2014/06/416w, https://taditdash.files.wordpress.com/2014/06/gridview-cell-showing-updated-value.png?

If we move our mouse on to the variables, which hold the cell values, we can see the old value instead of new updated value (Refer the debugging Screen Shot at the Top).

Some notes: Private Sub Fill Combinations() Dim DT As New Data Table DT = DA.

A Grid View Update Event Args object is passed to the event-handling method, which enables you to determine the index of the current row and to indicate that the update operation should be canceled.

To cancel the update operation, set the collections, if necessary, before the values are passed to the data source.

But the funny part is (for me) the event turned out to be inconsistance in its behaviour (i.e. And if someone else also facing similiar inconsistance behaviour, I'd advice to do like what I'll hopefully do; which is letting the user select the rows and clicks on a button (outside the grid) to delete them instead of embeded delete button within each row. Seconds Private Function Ok2Delete(By Val p Row As String) As Boolean If Session("Row Index") Is Nothing Or Else _ (CInt(Session("Rowindex")) = p Row And Also Date Time. This is a known issue and we are investigating fixing this in the next service pack.

Note: the example above shows how you can pass a value of another column on the same row that you wish to delete (ex: item_id is a field of another column in the same row) to your event handler that can help you delete a record from the database. NET in case anyone needs it: Private Function Ok2Delete(By Val p Row As String) As Boolean If Session("Row Index") Is Nothing Or Else _ (CInt(Session("Rowindex")) = p Row And Also Date Time. For the time being you could use the following work around.

Search for asp net gridview rowupdating firing twice:

asp net gridview rowupdating firing twice-16asp net gridview rowupdating firing twice-14

One obvious workaround is tochange the button type to a regular button or a link button.

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “asp net gridview rowupdating firing twice”