Inhertance issue for static items

2 posts, 0 answers
  1. Steele
    Steele avatar
    96 posts
    Member since:
    Mar 2008

    Posted 18 Jun 2010 Link to this post

    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.

  2. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 21 Jun 2010 Link to this post

    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
Back to Top