Client side event for datagrid control

X

Xavier Pacheco

This is probably a simple one, but I cannot seem to find an example.

I have a datagrid with each row containing

Checkbox | Textbox | Validation

When the checkbox column is checked for a given row, TextBox is
enabled, initialized with a value and the validation is enabled.

When the checkbox column is unchecked, Textbox is disabled, initialized
to Emtpy and validation is disabled.

Any pointers?
- xavier
 
L

Lamont

In your datagrids ItemDataBound event you have to do something like this...

szCheckScript &= "document.frmCC.dgContracts__ctl" & _
e.Item.ItemIndex + 2 & "_" & e.Item.Cells(7).Controls(7).ID & _
".disabled=false;"
szUnCheckScript &= "document.frmCC.dgContracts__ctl" & _
e.Item.ItemIndex + 2 & "_" & e.Item.Cells(7).Controls(7).ID & _
".disabled=true;"

tmpChkBox = CType(e.Item.Cells(2).Controls(1), CheckBox)
tmpChkBox.Attributes.Add("onclick", "if (this.checked) {" & _
szCheckScript & _
"} else {" & _
szUnCheckScript & _
"}")

View the source on your page when you run it and look at the names .NET
assigns to the checkbox controls in the datagrid. That will explain all the
ctl code where it is getting the name of the control.

Hope that makes sense.
 

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,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top