WebForms in a DataGrid
page 3 of 3
by . .
Feedback
Average Rating: 
Views (Total / Last 10 Days): 20975/ 45

Validation in a DataGrid

Validating in a DataGrid

Validating the data before it is even submitted saves a round-trip. However, for some database logic you may need to have a round-trip (for CustomValidators).

<asp:templatecolumn>
<itemtemplate>
<%# Container.DataItem("Age") %>
</itemtemplate>
<edititemtemplate>
<asp:RegularExpressionValidator runat="server" ControlToValidate="txtAge" ErrorMessage="Invalid input for Age"
ValidationExpression="[0-9]{2}" /><br>
<asp:textbox runat="server" id="txtAge" value='<%# Container.DataItem("Age") %>' />
</edititemtemplate>
</asp:templatecolumn>

Live Demo

This checks to make sure that it is a two digit number.

Summary

This article has more been about using TemplateColumns than using web forms, however we have used a series of server controls (RadioButton, checkbox and validation) in a DataGrid to give it more functionality. In the related article - "Using Dropdowns in DataGrids" I will explore using a DropDownList which is more complicated than the usual server controls.


View Entire Article

User Comments

Title: Data grid   
Name: manishsrivastava
Date: 2005-05-04 7:28:14 AM
Comment:
It is realy good for new users of asp.net & gide them how to work in right way.Continu providing codes i m greateful for that.
Title: nice content   
Name: mohit
Date: 2005-04-13 9:45:10 AM
Comment:
good content but u will have to work on your presentation buddy it is very cumbersome looking
Title: std   
Name: setiadi
Date: 2005-03-04 6:59:53 AM
Comment:
thank's for your information

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2021 ASPAlliance.com  |  Page Processed at 2021-12-01 8:21:49 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search