Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using findcontrol in a user control
Message
De
23/02/2011 07:32:39
 
 
À
23/02/2011 07:13:19
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01501388
Message ID:
01501407
Vues:
26
>>>>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

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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform