This is a migrated thread and some comments may be shown as answers.

Inhertance issue for static items

1 Answer 41 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Steele
Top achievements
Rank 1
Steele asked on 18 Jun 2010, 07:55 AM
Hello,

I have not been able to locate a solution to my problem, so thought I'd post it here.

I have created a class that extends the RCB (i.e public class MyComboBox : Telerik.Web.UI.RadComboBox { ...}).  Code omitted though it does do a fair bit of company centric implementation.  

I have placed two of these controls on a page, one dynamically loading items the other statically.  I have no issues with the dynamically loaded CB, Including the extended functionality, all works great. 
Though the statically loaded CB does not render the items, everything else seems fine! 

Statically loaded:
This displays an empty ComboBox.

Page code:
<cc1:MyComboBox ID="dl2" TabIndex="7" BackColor="White" Width="72px" runat="server" 
            Font-Size="12px" Font-Names="Arial" CssClass="txtBox">                                     
            <Items>                         
                <telerik:RadComboBoxItem Selected="True" Value="N/A"></telerik:RadComboBoxItem> 
                <telerik:RadComboBoxItem Value="Male" Text="Male"></telerik:RadComboBoxItem> 
                <telerik:RadComboBoxItem Value="Female" Text="Female"></telerik:RadComboBoxItem> 
            </Items>             
</cc1:MyComboBox> 


Dynamically loaded:
This is fine, the items are added in the code behind

<cc1:MyComboBox ID="dl1" TabIndex="1" BackColor="White" Width="160px" runat="server" 
            Font-Size="12px" Font-Names="Arial"
</cc1:MyComboBox> 



I have tried a simple extensions of the RadComboBoxItemCollection and RadComboBoxItem hoping that would help, but it did not.

 public class MyComboBoxItem : RadComboBoxItem 
    { 
        public MyComboBoxItem() 
        { 
        } 
    } 
 
    public class MyComboBoxItemCollection : RadComboBoxItemCollection 
    { 
         
        public MyComboBoxItemCollection():base(null) 
        { 
                          
        } 
 
        public MyComboBoxItemCollection(Control parent):base(parent) 
        { 
 
        } 
    } 

<cc1:MyComboBox ID="dl2" TabIndex="7" BackColor="White" Width="72px" runat="server"  
            Font-Size="12px" Font-Names="Arial" CssClass="txtBox">                                      
            <Items>                          
                <cc1:MyComboBoxItem  Selected="True" Value="N/A"></cc1:MyComboBoxItem>  
                <cc1:MyComboBoxItem Value="Male" Text="Male"></cc1:MyComboBoxItem>  
                <cc1:MyComboBoxItem Value="Female" Text="Female"></cc1:MyComboBoxItem>  
            </Items>              
</cc1:MyComboBox>  

I have a feeling I am missing one vital but simple requirement, though cannot for the life of me see what it is.

Any help would be appreciated.

Cheers.

1 Answer, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 21 Jun 2010, 05:18 PM
Hello Steele,

It would be hard to tell what exactly is causing this without having the code in front of me, still I would suggest you verify whether you have some code which clears the Items collection at some point. If such code exists, it is possible that it clears the Items after the statically defined ones have been created, so they get wiped out.

Sincerely yours,
Simon
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ComboBox
Asked by
Steele
Top achievements
Rank 1
Answers by
Simon
Telerik team
Share this question
or