Clientside validation for DataGrid's text boxes

K

Kris

Hi,
I have a DataGrid where in each row has couple of text boxes and an
update button. Each row is dynamically generated as the number of rows
are not known ahead of time. When the user clicks the update button, I
do a postback to capture the data entered. However I dont want to do a
postback when the textboxes are empty. How do I prevent this using
Clientside validation? This is a common problem and if it has been
beaten to death, please bear with me as I am new to Web Development.
Thanks in advance for any tips or pointers.

Kris.
 
P

Peter Blum

Use the RequiredFieldValidator on each textbox.

If you have multiple rows, each showing textboxes at the same time and you
only want the row being submitted to validate, you need "validation groups".
This is a feature introduced in ASP.NET 2.0 and already in my Professional
Validation And More (http://www.peterblum.com/vam/home.aspx) which is a
replacement to the Microsoft validators that greatly expands the
capabilities of validation and improves data entry web forms.

Validation groups lets you assign a group name to a submit button and its
list of validators so it only fires the validators on its list. My
Professional Validation And More is available for ASP.NET 1.x and does this
task better than ASP.NET 2.0's validators because it can automatically
create unique group names for each row in the datagrid.

Remember to always support server side validation by testing Page.IsValid is
true in the post back event handler for the submit button that validates.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top