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

ComboBox Column - how to set the values / datasource programmatically

1 Answer 248 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 20 Aug 2008, 01:19 PM
Hi..
I have a grid with comboboxes - how do I programmatically set the values and also set the data source in C#.

How do I find a ref to the control in the code behind?
thanks again

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 Aug 2008, 04:04 AM
Hello Jon,

I suppose that you are using a GridDropDownColumn.If so, you can access the ComboBox in the Column and set its DataSource and Values as shown below.
aspx:
<telerik:GridDropDownColumn UniqueName="ComboBox" DropDownControlType="RadComboBox">         
</telerik:GridDropDownColumn> 

cs:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem item = (GridEditableItem)e.Item; 
            RadComboBox rdcbx = (RadComboBox)item["ComboBox"].Controls[0]; 
            rdcbx.DataSourceID = "SqlDataSource1"
            rdcbx.DataTextField = "Place"
            rdcbx.DataValueField = "Place"
        } 
    } 

Princy.

Tags
Grid
Asked by
Jon
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or