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

[?] How can I bind a GridDropDownColumn with a list in code behind?

4 Answers 416 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tan
Top achievements
Rank 1
Tan asked on 21 Feb 2012, 04:14 PM
Hello All,
I have a RadGrid with a GridDropDownColumn. I want it contain a few item. this is my code:
code design:
            <Columns>

<telerik:GridDropDownColumn DataField="TinhTrang" UniqueName="clTinhTrang" HeaderText="Tình trạng">
                 </telerik:GridDropDownColumn>

   </Columns>
code behind: 
 ?????
 thanks all.
Tan

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 Feb 2012, 06:12 AM
Hello Tan,

Try setting DropDownControlType as RadComboBox and bind the DropDown as shown below.
aspx:
<telerik:GridDropDownColumn UniqueName="clTinhTrang" HeaderText="Tình trạng" DropDownControlType="RadComboBox"></telerik:GridDropDownColumn>

C#:
protected void RAdGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
 if (e.Item is GridEditableItem && e.Item.IsInEditMode)
 {
  GridEditableItem item = (GridEditableItem)e.Item;
  RadComboBox RadComboBox1 = (RadComboBox)item["clTinhTrang"].Controls[0];
  RadComboBox1.DataSourceID = "SqlDataSource1";
  RadComboBox1.DataTextField = "ShipCity";
  RadComboBox1.DataValueField = "ShipCity";
 }
}

-Shinu.
0
Tan
Top achievements
Rank 1
answered on 22 Feb 2012, 06:25 AM
Hello Shinu, Nice to see you again.
I already binded, but when I debug, value of GridDropDownColumn doesn't show in grid.
 I don't bind GridDropDownColumn with SqlDatasource, I bind it with a list.

List<string> list=new List<string>;
list.Add("item 1");
list.Add("item 2");
...
RadComboBox1.Datasource=list;

I don't know how to set ListValueField and ListTextField when I bind with list.
------------------------------------------------ 

Thanks you, 
Tan 
0
Tan
Top achievements
Rank 1
answered on 22 Feb 2012, 06:06 PM
who can help me? 
0
Shinu
Top achievements
Rank 2
answered on 23 Feb 2012, 05:15 AM
Hello,

Check the following help documentation which explains the same.
Customize/Configure GridDropDownColumn.

-Shinu.
Tags
Grid
Asked by
Tan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Tan
Top achievements
Rank 1
Share this question
or