Validating data, where to put server side data validation?

Topics: Developer Forum
Apr 9, 2007 at 9:23 PM
Your bulk edit gridview is amazing. We would like to add server side data validation when user presses the Save button. Do you have a sample of how/best place to add that? We have tried adding it to the Save method but cannot seem to get the right C# code to access the dirtyRows list. Our goal is to use the bulk edit gridview on multiple update pages, edits and messages to the user would vary based on data. We haven't found any samples of server side validation in the downloaded source.
Thank you. Karla
Jun 13, 2007 at 11:18 AM
I have a problem when using the BulkEditGridView with validation, and EnableInsert="True" - client-side validation is fired on the insert even when the the insert row hasn't changed.

I can't set the validation controls to be in separate groups, because there is a single "Save" button so I tried EnableClientScript="False" on the validation control. But server-side validation wasn't fired.

So I looked at the source, and in the Save method I changed this.UpdateRow(row, false) to this.UpdateRow(row, true) and this.InsertRow(row, false) to this.InsertRow(row, true). Now server side validation appears to work - the data is not submitted - but the validation controls don't display a message. Any way to get the messages to display?
Jun 13, 2007 at 1:41 PM
Actually, I've discovered that, setting the parameter for validation to true in the InsertRow and UpdateRow calls doesn't help me because it still validates the whole page, not just the fields that have been submitted. I've had to give up on EnableInsert. Instead I'm going to add the insert row to the footer and use a separate button for insert.