|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Can't access controls programmatically when inside FormView controlI have a FormView control that has a CheckBoxList in the Item template... I wrote this code to access a CheckBoxList in a FormView template... dim foo as checkboxlist foo = Me.fvVehicle.FindControl("cblSafety") foo.items(0).selected = true This code does not set the check box in the cbl. No errors, but nothing happens. If the checkBoxList is moved out of the the FormView control, then this works fine: cblSafety.Items(0).selected = true But I can't refernence the cbl control by name if it's in the FormView. Therefore this approach will not work at all. I also tried it by ID and it didn't work either... dim foo as Integer foo = me.fvVehicle.FindControl("cblSafety").ID dim bar as CheckBoxList bar = me.FindControl(foo) bar.Items(0).Selected = True Any thoughts? Bill Cincinnati, OH USA Ten to one you need to use a delegate to make the call.
Check your help file and google for delegate(s) information, then give it a try. I'm guessing it will fix your problem. Gardner Oh, and you will have to use Invoke to call the delegate in order to get
the control to function properly.... Maybe this will help: http://odetocode.com/Articles/116.aspx
nicomp wrote: Show quoteHide quote > Hello, > > I have a FormView control that has a CheckBoxList in the Item > template... > > I wrote this code to access a CheckBoxList in a FormView template... > > dim foo as checkboxlist > foo = Me.fvVehicle.FindControl("cblSafety") > foo.items(0).selected = true > > This code does not set the check box in the cbl. No errors, but nothing > happens. > > If the checkBoxList is moved out of the the FormView control, then this > works fine: > > cblSafety.Items(0).selected = true > > But I can't refernence the cbl control by name if it's in the FormView. > Therefore this approach will not work at all. > > I also tried it by ID and it didn't work either... > dim foo as Integer > foo = me.fvVehicle.FindControl("cblSafety").ID > dim bar as CheckBoxList > bar = me.FindControl(foo) > bar.Items(0).Selected = True > > > Any thoughts? > > Bill > Cincinnati, OH USA >
Sorting Arraylist Of Objects
System Idle Process Creating an array of datarows Pop up dialog after Main Form displayed CreateToolhelp32Snapshot (newbie -VB 2005 EE) TextBox question MenuItem vs. ToolStripMenuItem Datatable display help help Optimisation for shareware packages Define a Default Implementation for an Interface? |
|||||||||||||||||||||||