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

GridViewComboBoxColumn throwing input is not in a correct format

2 Answers 61 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 28 Sep 2010, 10:31 PM
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.

2 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 01 Oct 2010, 08:46 AM
Hi Jason,

I have tried to reproduce the issue you specified, but unfortunately I was not able to. I am sending you the sample project I have used for testing the problem. You may take a look at it and in case there is some misunderstanding according to your requirements, please fell free to modify it in the way you want. You may share any further relevant information so that I could provide with a more accurate solution, if the sample project does not help.
 

Sincerely yours,
Maya
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
Martin
Top achievements
Rank 1
answered on 04 Apr 2011, 05:00 PM
Out of interest you don't need more than one or two lines of code to crash the grid when binding to eNums, let me know and I can provide examples.
Tags
GridView
Asked by
Jason
Top achievements
Rank 1
Answers by
Maya
Telerik team
Martin
Top achievements
Rank 1
Share this question
or