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

Binding GridDropDownColumn and RadGrid on runtime

2 Answers 198 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andre Vovan
Top achievements
Rank 1
Andre Vovan asked on 23 Jul 2008, 08:30 PM
It seems that I can't bind GridDropDownColumn to any datasources in a RadGrid.  Is there anyway where I can bind it to the datasource through GridDropDownColumn?  as you can see, StateColumn.Datasource does not exist.

GridDropDownColumn StateColumn = new GridDropDownColumn();  
StateColumn.ListTextField = "Text";  
StateColumn.ListValueField = "Value";  
 
 
StateColumn.DataField = "StateOrRegion";  
StateColumn.HeaderText = "State"

//XmlDataSource States = new XmlDataSource();

//States.DataFile = "~Content/States.xml";

//States.ID = "StateDatasource";

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Jul 2008, 04:32 AM
Hello Peter,

You can set the DataSourceID of the GridDropDownColumn to the ID of the DataSource which will bind tht DropDown to the required DataSource.
cs:
  GridDropDownColumn StateColumn = new GridDropDownColumn(); 
  RadGrid1.MasterTableView.Columns.Add(StateColumn); 
  StateColumn.DataSourceID="StateDatasource"
  StateColumn.ListTextField = "Text"
  StateColumn.ListValueField = "Value"
  StateColumn.DataField = "StateOrRegion"
  StateColumn.HeaderText = "State";  

Thanks
Princy.

0
Andre Vovan
Top achievements
Rank 1
answered on 24 Jul 2008, 04:33 PM
you get an error that StateDatasource is not part of the DataSourceControl
Tags
Grid
Asked by
Andre Vovan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Andre Vovan
Top achievements
Rank 1
Share this question
or