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

[Solved] RadComboBox inside template

4 Answers 138 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jan
Top achievements
Rank 1
Jan asked on 17 Aug 2009, 08:28 AM
Hello!

Is it possible to access a RadComboBox's selected value onSelectedIndexChanged event
using FindControl()? Or any other way? The ComboBox is inside an edittemplate.

Thank you for any reply!

Janne P

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Aug 2009, 09:31 AM
Hello Janne,

To retrieve the selected value of the combobox in the SelectedChanged event of the combobox, you can try out the following code:
c#:
 protected void RadComboBox1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) 
    { 
        RadComboBox combo = (RadComboBox)o; 
        string strtxt = combo.SelectedValue; 
                
    } 

and if you want to access the selected value of the combobox on updating a record, you can try the following code:
c#:
  protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "Update"
        { 
            GridEditableItem editedItem = e.Item as GridEditableItem; 
            string strtxt = ((RadComboBox)editedItem.FindControl("RadComboBox1")).SelectedValue;        
 
        } 
    } 

Thanks
Shinu.
0
Jan
Top achievements
Rank 1
answered on 17 Aug 2009, 11:38 AM
Hello!

Thanks for your quick response Shinu!
I think missled you in my question though. I need to access another ComboBox
in the OnSelectedIndexChanged event.
When CB_1 is changed I want CB_2 to load something else from the db depending
on the selection i CB_1.
I've found samples how to achive this on this forum and elsewhere but not when
the ComboBox is in an EditTemplate.

Thanks again.

Regards

Janne P
0
Princy
Top achievements
Rank 2
answered on 18 Aug 2009, 04:33 AM
Hello Janne,

You can try out the following code to access a combobox in the SelectionIndexChanged event of another combobox:
c#:
protected void ComboBox1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) 
    { 
        RadComboBox combo1 = (RadComboBox)o; 
        GridEditableItem edititem = (GridEditableItem)combo1.NamingContainer; 
        RadComboBox combo2 = (RadComboBox)edititem.FindControl("ComboBox2ID"); 
        if(combo1.SelectedValue=="2"
        { 
            combo2.DataSourceID = "SqlDataSource2"
            combo2.DataTextField = "ContactTitle";             
        } 
    } 

Thanks
Princy.
0
Jan
Top achievements
Rank 1
answered on 18 Aug 2009, 08:50 AM
Thank you Princy!

That did the trick. I'm really greatful for yours and Shinu's
quick replys.

Regards

Janne
Tags
Grid
Asked by
Jan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jan
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or