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

[Solved] RadComboBox inside a detailtable

1 Answer 109 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Fabio Sales
Top achievements
Rank 1
Fabio Sales asked on 17 Sep 2009, 02:44 PM

Hi.

I have a radgrid with a one detailtable, inside this detail, i have two radcombox, in the insert of the new row, i'm trying to populate the second radcombox with the value from the first radcombox using the event OnSelectedindexChanged, but i'm not getting find the control radcombobox, i'm using the code bellow , but i know that this code is wrong, because I know I need to get index of the line,  but i don't how to get. Could you help-me?

 sqlTarget.SelectCommand = "SELECT* FROM tb_tar_target where  and mov_c_divisao = '" & CType(rdgWorkFlow.MasterTableView.DetailTables(0).FindControl("rdbnil_c_divisao"), RadComboBox).SelectedItem.Text

 CType(rdgWorkFlow.MasterTableView.DetailTables(0).FindControl("rdbnil_tar_n_codigo"), RadComboBox).DataSource = sqlTarget
 CType(rdgWorkFlow.MasterTableView.DetailTables(0).FindControl("rdbnil_tar_n_codigo"), RadComboBox).DataBind()

excuse-me by my english

thanks

Fabio

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 Sep 2009, 06:41 AM
Hello Fabio,

Inorder to populate a combobox based on the item selected in another combobox, both comboboxes being placed in the DetailTable of a grid, when the detail table is in InsertMode only, you can try the following code:
c#:
protected void rdgWorkFlow_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted && e.Item.OwnerTableView.Name == "Detail"
        { 
            GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item; 
            RadComboBox combo = (RadComboBox)insertItem.FindControl("rdbnil_c_divisao"); 
            combo.AutoPostBack = true
            combo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(combo_SelectedIndexChanged); 
        } 
    } 
 
void  combo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) 
    RadComboBox combo1 = (RadComboBox)o; 
    RadComboBox combo2 = (RadComboBox)combo1.NamingContainer.FindControl("rdbnil_tar_n_codigo"); 
    if (combo1.SelectedItem.Text == "Text1"
    { 
        combo2.DataSourceID = "SqlDataSource2"
        combo2.DataTextField = "Column2"
    } 
 

Thanks
Princy.
Tags
Grid
Asked by
Fabio Sales
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or