Client side validation of a DataGrid

H

Hrvoje Vrbanc

Hello all,

I have a problem that looks simple and I think should be fairly common but
wasn't able to find a solution yet. Here it is: I have a DataGrid control
displaying data from a database. There's also a column with empty TextBox
controls and another one with Button controls in the DataGrid. I would like
to create a JavaScript client side validation that will check if a number
has been entered in a TextBox near the Button clicked. The Button's function
is to put a quantity of a product into a database, quantity of course being
entered into TextBox. Now, of course the problem isn't in the JavaScript but
how should I wire the OnClick event of each particular Button to JavaScript
and how to pass the value (text) of belonging TextBox to JavaScript?


I have tried plenty of options but if I use DataGrid's
OnSelectedIndexChanged event, it only initiates JavaScript when the same
Button is pressed for the second time, if I use OnItemDataBound event, the
JavaScript gets called but no value is passed from the TextBox to JavaScript
and if I put validator within the DataGrid in HTML view, it requires all
TextBox controls to be filled, not just the one near the clicked Button.

I'm sure there must be an easy way to do it because it seems to me like a
quite usual requirement.

Thank you very much in advance,
Hrvoje
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top