Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using findcontrol in a user control
Message
From
23/02/2011 10:20:39
 
 
To
23/02/2011 09:42:13
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01501388
Message ID:
01501453
Views:
39
>>>>>>>HI
>>>>>>>
>>>>>>>I've got a page that contains a user control which load some telerik comboboxes.
>>>>>>>
>>>>>>>In the page load I'm trying to set some checkbox values on the combo controls but when I try to get the items in the control it returns 0
>>>>>>>
>>>>>>>any ideas what I'm doing wrong.
>>>>>>>
>>>>>>>Thanks
>>>>>>>
>>>>>>>(the code is below)
>>>>>>>
>>>>>>>
>>>>>>> Dim radModels As Telerik.Web.UI.RadComboBox = DirectCast(Me.DateRangeSelector1.FindControl("radModels"), Telerik.Web.UI.RadComboBox)
>>>>>>>                For Each item As Telerik.Web.UI.RadComboBoxItem In radModels.Items
>>>>>>>                    Dim chk As CheckBox = DirectCast(item.FindControl("chk1"), CheckBox)
>>>>>>>                    If item.Text <> ModelName Then
>>>>>>>                        chk.Checked = False
>>>>>>>                    Else
>>>>>>>                        chk.Checked = True
>>>>>>>                    End If
>>>>>>>                Next
>>>>>>>
>>>>>>I don't have the Telerik stuff and I see the RadComboBoxItem overrides the native WebControl.FindControl() method (http://www.telerik.com/help/aspnet/combobox/radcombobox-telerik.webcontrols.radcomboboxitem-findcontrol.html) without descibing how the behaviour is changed. Anyway it's not clear to me where you're problem really lies.
>>>>>>Are there no items in the radModels collection?
>>>>>>If there are does .FindControl("chk1") return anything before the cast?
>>>>>
>>>>>Hi Viv
>>>>>
>>>>>radModels has an item count of 0 so I assume I'm not getting it correctly.
>>>>
>>>>You might need to do this in the LoadComplete event rather than Load - I'm not sure all controls are instantiated until then.....
>>>>(http://msdn.microsoft.com/en-us/library/ms178472.aspx)
>>>
>>>I think I may need to do this differently
>>>
>>>The order of events I get (stepping through in Visual Studio) is
>>>Page init
>>>Page Load Complete
>>>Page Load
>>>dateRangeSelector Page Load
>>>
>>>then it drops into the html view where its loading the items onto the combo box
>>
>>Hmmm. I haven't got ASP.NET up at the moment and relied on memory (plus what it says in the link:)
>>SNIP:
>>"LoadComplete - Use this event for tasks that require that all other controls on the page be loaded"
>>
>>>So how or where would alter that.
>>>
>>>I've got a list of items with checkboxes and depending on a parameter passed via a querystring I want to have the checkbox checked or unchecked.
>>>
>>>Thanks Viv
>>>
>>>BTW "I give up" is a perfectly reasonable reply.
>>And, I'm afraid, the one I have to give at the moment (doing a bit of fire-fighting). Maybe later.....
>
>Thanks Viv
>
>I hope you put your fire out

I think so. Just going to keep an eye on the ashes for a while :-}

>
>Looks like
>
>radModels_ItemDataBound
>
>is the way to go

So you're sorted ?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform