Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if value already exists in gridview.

Status
Not open for further replies.

Crowley16

Technical User
Jan 21, 2004
6,931
GB
A newbie to asp.net so go easy please...

Basically, I've got a gridview with update and insert. What I want to do is, when column1 is changed, before the save happens, check if the new value already exists somewhere else in column1 and if so, prompt the user to either overwrite or discard the new entry.

Not even sure how to start with this so any help appreciated.

--------------------
Procrastinate Now!
 
I would check if that value exists in the DB, not in the grid itself.
 
That would be ok as well.

but how do I do this check and feed back to the user before the event has happened?

--------------------
Procrastinate Now!
 
There are two ways to do it. Either use Javascript to loop through the existing values and compare (throwing up an error/alert when required), or alternatively you could check the database using AJAX.
 
In what ever you save event is, pass the value the user entered into a sp and that sp will check if the value exits. Return a value to the front end with an output parameter and then do what you have to do based on that value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top