By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,433 Members | 776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,433 IT Pros & Developers. It's quick & easy.

Clientside validation for DataGrid's text boxes

P: n/a
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.
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Kris" <kr**@freemail.com> wrote in message
news:ek**************@TK2MSFTNGP15.phx.gbl...
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.

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.