RadComboBox witin ItemTemplate

4 posts, 0 answers
  1. Sean
    Sean avatar
    13 posts
    Member since:
    Jan 2009

    Posted 20 Jan 2009 Link to this post

    Hi,

    Using C# I have programatically added a RadToolBarButton (a), which has an ItemTemplate containing a RadComboBox (b).
    I also have another RadToolBarButton (c).

    When I click (c) I would like to know the SelectedItemIndex of (b).

    I have tried attaching to the SelectedIndexChanged event of the RadComboBox when the ItemTemplate is bound, however the event never fires.

    Any help would be greatly appreciated as I am against a brick wall here!

    Sean Duffy.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 21 Jan 2009 Link to this post

    Hello Sean,

    If you want to access the SelectedIndex of a combobox placed in the ItemTemplate of a RadToolBarButton, on clicking another RadToolBarButton, you can try out the following code in the ButtonClick event of the RadToolBar:
    cs:
     protected void RadToolBar1_ButtonClick(object sender, RadToolBarEventArgs e) 
        { 
            if (e.Item.Text == "ButtonAText") 
            { 
                foreach (RadToolBarItem btn in RadToolBar1.Items) 
                { 
                    RadComboBox combo = (RadComboBox)btn.FindControl("RadComboBoxB"); 
                    if (combo != null) 
                    { 
                        int index = combo.SelectedIndex; 
                    } 
                     
                } 
            } 
        } 

    Thanks
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. sp
    sp avatar
    8 posts
    Member since:
    Jan 2009

    Posted 28 Jan 2009 Link to this post

    Hi,

    I have a similiar scenerio but I would like to access the SelectedIndexChanged event of the RadComboBox. I have some code to be placed within this event. Is it possible?
    Thanks.
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 29 Jan 2009 Link to this post

    Hello,

    You can try out the following code in the PreRender event of the ToolBarButton to trigger the SelectedIndexChanged event:
    cs:
    protected void Page_Load(object sender, EventArgs e) 
        { 
            foreach (RadToolBarItem btn in RadToolBar1.Items) 
            { 
                RadComboBox combo = (RadComboBox)btn.FindControl("RadComboBox2"); 
                if (combo != null) 
                { 
                    combo.AutoPostBack = true
                    combo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(combo_SelectedIndexChanged);  
                } 
            } 
       } 
     
    void combo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) 
        { 
             
        } 

    Thanks
    Princy.
Back to Top