views:

17

answers:

1

Does anyone know how to do validation for a unique property or can point me to an example?

Say I have a grid of movies and I do an edit or an insert. If I set the textbox 'Title' to be 'A really cool movie'. How would I do the validation to ensure the database doesn't already contain a movie by this title? Would I use a CustomValidator? I tried doing this but when I was checking the text in the textbox it was coming through as an empty string.

Thanks!

Mr Cricket

A: 

Yes, this is a perfect scenario for a Custom Validator. However, unless you are using AJAX, they only validate when a post-back occurs. Without knowing more about your exact setup, this is all I can provide.

colithium
I'm using an AJAXified Grid. When I when into the CustomValidator which fired correctly. I just wasn't too sure what to do in the event because I couldn't get the text from the textbox
Mr Cricket
Ok, that works fine. I just needed to get the text from the text box so I used FindControl. Would of preferred some other method.
Mr Cricket
Well, my guess is that the text box isn't being posted-back. That's part of the appeal of AJAX. Make sure that that is happening and you can do it the "right way"
colithium