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

GridDropDownColumn setting DataSource separately

3 Answers 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nicolas
Top achievements
Rank 1
Nicolas asked on 14 Aug 2012, 12:26 PM
Hi

I'm trying to make a RadGrid with cascadingcombo boxes. I'm new to Telerik so i have no clue what i'm doing at the moment. I tried to make the DropDown colum his datasource a list that i get from the DB trough Linq and trough a DTOmapper. So the thing is i can't attach my list of dto's to the comboboxcolum ! Because it only takes a string and not a List of objects. Does anyone know what i'm doing wrong or am i completly forgetting something ?

Ill attach my code
private void LoadBehandelaars(int toInt32)
     {
         DataTable behandelaar = new DataTable();
         List<User> Behandelaars = _clientenFunctions.GetBehandelaarsByDiscipline(Convert.ToInt32(Session["cate"]));
         behandelaar.PrimaryKey = new DataColumn[]{ behandelaar.Columns.Add("NestorNummer",typeof(string))};
         behandelaar.Columns.Add("UserName", typeof (string));
 
         foreach (User user in Behandelaars)
         {
             behandelaar.Rows.Add(new object[]
                                      {
                                          user.NestorNummer, user.UserName
                                      }
                 );
         }
 
         GridDropDownColumn BehanderlaarColumn = new GridDropDownColumn();
         BehanderlaarColumn.HeaderText = "Behandelaar";
         BehanderlaarColumn.DataSourceID = behandelaar.ToString();
     }

3 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 17 Aug 2012, 10:35 AM
Hi Nicolas,

The built-in GridDropDownColumn is designed to be used mainly with DataTables in order to easily map and generate their dropdown items values in conjunction with the DataField/ListValueField/DataSourceID/ListDataMember values of the column. For custom objects collections consider replacing the GridDropDownColumn with template column holding RadComboBox in its edit template (generating/binding the items for the RadComboBox inside the ItemDataBound handler of RadGrid).
Check this demo which demonstrates how to implement RadComboBox into GridTemplateColumn.

Greetings,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
K
Top achievements
Rank 1
answered on 04 Jun 2013, 05:25 PM
If I have a response object that I am converting into tables.  Part of that response object contains tables that are use to populate GridDropDownColumns.  The table creation happens in the code-behind.  How do I link the GridDrownDownColumn's data source to the table that was created in the code-behing.  The datasourceid is specified in the ASPX.  Is there a way to do that?  It is almost like I need to "Bind" event for the GridDropDownColumn.
0
Kostadin
Telerik team
answered on 07 Jun 2013, 10:19 AM
Hello,

I am afraid for such scenario you have to use a TemplateColumn with RadComboBox as and EditTemplate. The provided demo from my previous reply will help you figure out how you can achieve that.

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Nicolas
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
K
Top achievements
Rank 1
Share this question
or