This is a migrated thread and some comments may be shown as answers.

How do I validate a field and prevent an insertion based on the result of the validation

4 Answers 113 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 23 Jul 2010, 04:46 PM

I have a radgrid with one column called ApplicationName.  When I click the "Add New Record" button to add a new record and fill out the textbox, I want to check the textbox to make sure there is not a duplicate ApplicationName in the database.  How do I access the textbox to perform validation on it and what event do I place the code inside.  I thought it would be the ItemCommand evnet but it seems to happen after the insert is completed.

Do you have an example?  I looked at the examples on the website and could not find something to use.

4 Answers, 1 is accepted

Sort by
0
Accepted
Cori
Top achievements
Rank 2
answered on 23 Jul 2010, 06:06 PM
Firstly, you should turn of AllowAutomaticUpdates/AllowAutomaticInserts, if you have it enabled, since you can't perform the check using that feature. Next you should handle the InsertCommand/UpdateCommand of the grid to perform you duplicate check. If it fails stop the update from happening

I hope that helps.
0
sxd9mm
Top achievements
Rank 1
answered on 24 Nov 2010, 07:18 PM
Cori, you are not helping :o(
Read Richards post. He needs to know exactly how to validate the field (so do I).
And your advise is like: Yeah, you can do it.
Thanks for nothing.
0
Diego
Top achievements
Rank 1
answered on 29 Nov 2010, 08:58 AM
I hate to interfere in such discussions but hey, you are behaving strange. Cori is obviously trying to help and I suppose he is not obliged to do so. Not to say that this thread is 4 months old. In my opinion you shoot yourself in the foot with such answers.
Don't get me wrong, this is just my 2c.

Here is something you could start with:

http://www.telerik.com/help/aspnet-ajax/grdvalidation.html

http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/validation/defaultcs.aspx

http://www.telerik.com/community/forums/aspnet-ajax/grid/radgrid-perform-validation-only-in-edit-or-insert-mode-and-not-both.aspx

Cheers
0
sxd9mm
Top achievements
Rank 1
answered on 29 Nov 2010, 04:24 PM
Diego,
You just did wat Cori supposed to: YOU ACTUALLY HELPED WITH YOUR POST!
As I understand you should post in here in case you have a question or you have an answer to somebody's question.
Nobody needs to be cheered up with something like 'Yeah, you can do it! Keep looking.'
You can think that I'm strange but that's what I think. This is not a social network but developer's one.
Thank you for your help!
Tags
Grid
Asked by
Richard
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
sxd9mm
Top achievements
Rank 1
Diego
Top achievements
Rank 1
Share this question
or