This is actually a combobox within the RadGridView but my c# syntax/datastructure problem is the same. I need a list with two items ClassName and ClassID for a combobox. The possible key-value pairs will be 'A'-0 'B'-2, 'C'-3 and 'D'-4 .
I've been provided a table from a client with either the values "A or B" or "A,B,C,D". (Picture of table info below) I need to translate either of those two possibilities into two possible collections to bind to a combobox. Either the combobox displays an A and B, or A and B and C and D. When the user makes a selection and saves.... the collection (rows in datagrid) will contain within it the key-value pair selected. That value will be returned to target table also pictured below with it's possible values.
If someone can see where I'm trying to go with this I would appreciate any comments or suggestions, even if that comment is I'm not clear what I'm trying to do. I'm stuck with these tables. Below is my idea of a model and then a switch statement I need to put somewhere to translate the incoming value into a form the combo box will require. (to bind to) Thanks for helping me work through this design process in an area new to me. greg
public class Model : INotifyPropertyChanged { private string _ClassName; private string _ClassID; public Model(Model) { } public string ClassName{ get { return _ClassName; } set { _ClassName= value; RaisePropertyChanged ("ClassName"); } } public string ClassID{ get { return _ClassID; } set { _ClassID= value; RaisePropertyChanged("ClassID"); } } public event PropertyChangedEventHandler PropertyChanged; private void RaisePropertyChanged(String propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (null != handler) { handler(this, new PropertyChangedEventArgs(propertyName)); } } }
switch (incoming 'Class' field value in collection) { case "A or B": AorB(); break; case "A, B, C, D": ABCD(); break; } private ObservableCollection<ClassName> AorB() { ObservableCollection<ClassName> _ClassNames = new ObservableCollection<ClassName>(); ClassName _className; className = new ClassName ("A", 1); _ClassNames.Add(className ); className = new ClassName ("B", 2); _ClassNames.Add(className ); return _ClassNames ; } private ObservableCollection<ClassName> ABCD() { ObservableCollection<ClassName> _ClassNames = new ObservableCollection<ClassName>(); ClassName _className; className = new ClassName("A", 0); _ClassNames.Add(className ); className = new ClassName("B", 1); _ClassNames.Add(className ); className = new ClassName("C, 2) _ClassNames.Add(className ); className = new ClassName("D, 3); _ClassNames.Add(className ); return _ClassNames ; }
Source table
Target table where values will be saved once selected