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

RadComboBox witin ItemTemplate

3 Answers 141 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 1
Sean asked on 20 Jan 2009, 12:57 PM
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.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 Jan 2009, 11:51 AM
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.
0
sp
Top achievements
Rank 1
answered on 28 Jan 2009, 09:42 PM
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.
0
Princy
Top achievements
Rank 2
answered on 29 Jan 2009, 08:02 AM
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.
Tags
ToolBar
Asked by
Sean
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
sp
Top achievements
Rank 1
Share this question
or