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
222 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 33

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

808 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