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

GridDropDownColumn - bind to list

2 Answers 180 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JH
Top achievements
Rank 1
JH asked on 13 Jul 2010, 01:05 PM
Hi,

I've found several examples of how to bind GridDropDownColumns to SQLDataSources and such, but not how to bind such column to an ordinary List or DataTable.
I know that I can use a GridTemplateColumn containing a dropdown-control and populate the control in the event handler of ItemDataBound, but a more direct approach where the column is bound to something in the grid's datasource would be a lot nicer.
Is this possible?

Thanks!

2 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 15 Jul 2010, 01:39 PM
Hello JH,

Besides declarative data source controls, the GridDropDownColumn can bind to tables from DataSets. When your RadGrid data source is a DataSet containing different tables, the DataMember property of the GridDropDownColumn specifies the name of the table from this DataSet that the column will use.

No other binding scenarios besides data source controls and DataSets are supported by the GridDropDownColumn. For more complex binding, we recommend using the GridTemplateColumn  with a RadComboBox in  the EditItemTemplate.

All the best,
Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
John Mann
Top achievements
Rank 1
answered on 01 Sep 2010, 01:29 AM
This works for me,

// define the list in the appropriate scope
private static List<string> listNameSuffix = new List<string> { "", "DR", "MR", "MRS", "MS", "PHD", "ESQ", "JR", "SR", "II", "III" };
  
// then attach it to the list in this event
void rgInterpreter_CreateColumnEditor(object sender, GridCreateColumnEditorEventArgs e)
{
  GridDropDownColumnEditor myEditor = e.ColumnEditor as GridDropDownColumnEditor;
  
  switch (e.Column.UniqueName)
  {
    case "gdcSuffix":
      myEditor.DataSource = listNameSuffix;
      break;
    default:
      break;
  }
}
Tags
Grid
Asked by
JH
Top achievements
Rank 1
Answers by
Veli
Telerik team
John Mann
Top achievements
Rank 1
Share this question
or