We have a grid being dynamically created using the following code:
RadGridView gv = new RadGridView();
gv.AutoGenerateColumns = false;
gv.ShowColumnFooters = false;
gv.ShowGroupPanel = false;
gv.ShowInsertRow = true;
gv.AddingNewDataItem += new EventHandler<Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs>(gv_AddingNewDataItem);
GridViewDataColumn col = new GridViewDataColumn();
col.Header = "Choice";
col.UniqueName = "Choice";
col.Width = new GridViewLength(60, GridViewLengthUnitType.Star);
gv.Columns.Add(col);
col = new GridViewDataColumn();
col.Header = "Score";
col.UniqueName = "Score";
col.Width = new GridViewLength(10, GridViewLengthUnitType.Star);
gv.Columns.Add(col);
GridViewComboBoxColumn comboCol = new GridViewComboBoxColumn();
comboCol.Header = "AcceptanceCriteria";
comboCol.UniqueName = "AcceptanceCriteria";
comboCol.DataMemberBinding = new Binding("AcceptanceCriteria");
AcceptanceCriteriaTypes aTypes = new AcceptanceCriteriaTypes();
comboCol.ItemsSource = aTypes;
comboCol.DisplayMemberPath = "CName";
comboCol.SelectedValueMemberPath = "CType";
comboCol.Width = new GridViewLength(30, GridViewLengthUnitType.Star);
gv.Columns.Add(comboCol);
The grid is then bound to our data source object, which is also dynamically created (so I won't post it here, the code won't make any sense)
AcceptanceCriteriaTypes is created through this simple class that creates a selection of possible values in an enum:
public enum AcceptanceCriteriaEnum
{
Favorable,
Neutral,
Unfavorable
}
public class AcceptanceCriteriaType
{
public AcceptanceCriteriaEnum CType { get; set; }
public string CName { get; set; }
}
public class AcceptanceCriteriaTypes : ObservableCollection<AcceptanceCriteriaType>
{
public AcceptanceCriteriaTypes()
{
Add(new AcceptanceCriteriaType() { CType = AcceptanceCriteriaEnum.Favorable, CName = "Favorable" });
Add(new AcceptanceCriteriaType() { CType = AcceptanceCriteriaEnum.Neutral, CName = "Neutral" });
Add(new AcceptanceCriteriaType() { CType = AcceptanceCriteriaEnum.Unfavorable, CName = "Unfavorable" });
}
}
The data object that the ComboBoxColumn is binding to is of type AcceptanceCriteriaEnum, so the data type agrees with the combo box. However, when you choose an item from the combo box, the column throws a "Input is not in a correct format." validation error. I've verified that the bound data types agree, and it isn't our binding throwing the validation error as the source binding validation event isn't being thrown yet - focus is staying inside the cell. We are using RadControls 2010 Q2 SP1. Any help would be appreciated.
RadGridView gv = new RadGridView();
gv.AutoGenerateColumns = false;
gv.ShowColumnFooters = false;
gv.ShowGroupPanel = false;
gv.ShowInsertRow = true;
gv.AddingNewDataItem += new EventHandler<Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs>(gv_AddingNewDataItem);
GridViewDataColumn col = new GridViewDataColumn();
col.Header = "Choice";
col.UniqueName = "Choice";
col.Width = new GridViewLength(60, GridViewLengthUnitType.Star);
gv.Columns.Add(col);
col = new GridViewDataColumn();
col.Header = "Score";
col.UniqueName = "Score";
col.Width = new GridViewLength(10, GridViewLengthUnitType.Star);
gv.Columns.Add(col);
GridViewComboBoxColumn comboCol = new GridViewComboBoxColumn();
comboCol.Header = "AcceptanceCriteria";
comboCol.UniqueName = "AcceptanceCriteria";
comboCol.DataMemberBinding = new Binding("AcceptanceCriteria");
AcceptanceCriteriaTypes aTypes = new AcceptanceCriteriaTypes();
comboCol.ItemsSource = aTypes;
comboCol.DisplayMemberPath = "CName";
comboCol.SelectedValueMemberPath = "CType";
comboCol.Width = new GridViewLength(30, GridViewLengthUnitType.Star);
gv.Columns.Add(comboCol);
The grid is then bound to our data source object, which is also dynamically created (so I won't post it here, the code won't make any sense)
AcceptanceCriteriaTypes is created through this simple class that creates a selection of possible values in an enum:
public enum AcceptanceCriteriaEnum
{
Favorable,
Neutral,
Unfavorable
}
public class AcceptanceCriteriaType
{
public AcceptanceCriteriaEnum CType { get; set; }
public string CName { get; set; }
}
public class AcceptanceCriteriaTypes : ObservableCollection<AcceptanceCriteriaType>
{
public AcceptanceCriteriaTypes()
{
Add(new AcceptanceCriteriaType() { CType = AcceptanceCriteriaEnum.Favorable, CName = "Favorable" });
Add(new AcceptanceCriteriaType() { CType = AcceptanceCriteriaEnum.Neutral, CName = "Neutral" });
Add(new AcceptanceCriteriaType() { CType = AcceptanceCriteriaEnum.Unfavorable, CName = "Unfavorable" });
}
}
The data object that the ComboBoxColumn is binding to is of type AcceptanceCriteriaEnum, so the data type agrees with the combo box. However, when you choose an item from the combo box, the column throws a "Input is not in a correct format." validation error. I've verified that the bound data types agree, and it isn't our binding throwing the validation error as the source binding validation event isn't being thrown yet - focus is staying inside the cell. We are using RadControls 2010 Q2 SP1. Any help would be appreciated.