Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
266 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 34

Assisted Solution

by:Mike Eghtebas
Mike Eghtebas earned 800 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 36

Accepted Solution

by:
Miguel Oz earned 1200 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

670 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