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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top