Solved

Why the gridView_RowUpdating events get hit again when I refresh the page after it completed the update?

Posted on 2014-12-22
2
230 Views
Last Modified: 2014-12-26
Hi, I'm using VS2012.

After the end of the gridView_RowUpdating, I set the EditIndex to -1.  Doesn't this signal that updating event is completed?  The gridview returns to the original state and the UPdate and Cancel button goes away.  I then click Refresh (in the browser next to the url) icon to refresh the page, then it hit my break point in VS that is in gridView_RowUpdating event.  

Why is it hitting that updating event code again?  How to fix this?  Thank you.
0
Comment
Question by:lapucca
2 Comments
 
LVL 34

Assisted Solution

by:Mike Eghtebas
Mike Eghtebas earned 200 total points
ID: 40514424
let's have a Boolean variable (bolBypass) to be set to true or false (in postback == true or postback != true whichever you are using).

Then use:
if bolBypass== true 
{
// run your update routine
bolBypass = false  // this resetting will prevent update running for 2nd time
}

Open in new window


You need to figure out the location and setting of  bolBypass = ? in your  postback == true or postback != true.
0
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 300 total points
ID: 40515840
Tricky hard to say without looking at the whole page code,
if your code is firing two times only, then your issue may get solved as follows:
1) Check that your event handler is not being set more than once in your site.
For example you may be defining the handler on your grid view mark-up and C#code.
2) Check that your code is not updating the database after the data is bound to the grid view.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question