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
206 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now