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

GridViewComboBoxColumn not displaying the value when binding RadGridView to Datable.DefaultView

1 Answer 249 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rathish
Top achievements
Rank 1
Rathish asked on 17 Jul 2015, 07:53 AM

In the below attached Code Snippet, ​While trying to generate a gridview dynamically , I was not able to bind the values of Datable to to Combox Column.

I have tried populating combox items but when I select a Value its saving back to the Datatable.

Please help me out to bind the Datable Value to Combo box selected value and save the new item selected from the combox list back to the Datatable

 

 


this.ItemsGrid.ItemsSource = this.Datable1.DefaultView;
List<LOV> lovs = new List<LOV>();
lovs.Add(new LOV { Id= "1", Value = "test1" });
lovs.Add(new LOV { Id= "2", Value = "​test2" });
lovs.Add(new LOV { Id= "3", Value = "​test3" });
lovs.Add(new LOV { Id= "4", Value = "​test4" });
lovs.Add(new LOV { Id= "5", Value = "test5" });

foreach ( Car cr in Cars)
{
switch (cr.CONTROL_TYPE.ToUpper())
{
case "COMBOBOX":
Telerik.Windows.Controls.GridViewComboBoxColumn comboBoxColumn = new Telerik.Windows.Controls.GridViewComboBoxColumn();                       comboBoxColumn.DataMemberBinding = new Binding(cr.Name);
comboBoxColumn.ItemsSource = lovs;
comboBoxColumn.DisplayMemberPath = "Value";
comboBoxColumn.SelectedValueMemberPath = "Id";
comboBoxColumn.Header = cr.Name;
this.ItemsGrid.Columns.Add(comboBoxColumn);
break;

case "TEXTBOX":
Telerik.Windows.Controls.GridViewDataColumn txtBoxColumn = new Telerik.Windows.Controls.GridViewDataColumn();
txtBoxColumn.DataMemberBinding = new Binding(cr.Name);
txtBoxColumn.Header = cr.Name;
this.ItemsGrid.Columns.Add(txtBoxColumn);
break;

case "CHECKBOX":
Telerik.Windows.Controls.GridViewCheckBoxColumn chkBoxColumn = new Telerik.Windows.Controls.GridViewCheckBoxColumn();
chkBoxColumn.DataMemberBinding = new Binding(cr.Name);
chkBoxColumn.Header = cr.Name;

this.ItemsGrid.Columns.Add(chkBoxColumn);
break;
}
}


public class LOV
{       
public string Id {get;set;}
public string Value{get;set;}
}

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 20 Jul 2015, 12:35 PM
Hello,

Does value cr.Name (comboBoxColumn.DataMemberBinding) correspond to value LOV.Id (comboBoxColumn.SelectedValueMemberPath)? You can also refer to the documentation on how to configure and work with ComboBox Column.

There is also a problem troubleshooted at this online article.

Regards,
Dimitrina
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Rathish
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or