Hi!
We are amazed with your controls for WPF, specially with RadDataForm.
But, we have one problem.
We need ComboBoxField to choose which Company has produced the Product.
And it's working well, but when we add new product and click OK, a NullReferenceException pops out.
Our code:
Company.cs
Product.cs
And our AutoGeneratingField event of RadDataForm:
And once again, this is working OK, but when we proceed with adding new product, NullReferenceException pops out because Company property of Product for adding is null.
Where we sin?
P.S: Sorry for our terrible English, we're from Serbia, and we implemented all CRUD operations with RadDataForm events (EditEnded, AddedNewRecord...).
Thanks in advance!
DMSoft
We are amazed with your controls for WPF, specially with RadDataForm.
But, we have one problem.
We need ComboBoxField to choose which Company has produced the Product.
And it's working well, but when we add new product and click OK, a NullReferenceException pops out.
Our code:
Company.cs
class Company : IDataErrorInfo { public int _id; public int id { get { return _id; } set { _id = value; } } public string _name; public string name { get { return _name; } set { _name= value; } } public string Error { get; set; } public string this[string columnName] {// . . . } public static void Add(Company ist) {// . . . } public static void Edit(Company ist) {// . . . } public static void Delete(Company ist) {// . . . } public static List<Company> Get() {// . . . }
} class Product: IDataErrorInfo { public int _id; public int id { get { return _id; } set { _id = value; } } public string _name; public string name { get { return _name; } set { _name= value; } } public Company _comp; public Company comp { get { return _comp; } set { _comp= value; } } public string Error { get; set; } public string this[string columnName] {// . . . } public static void Add(Product ist) {// . . . } public static void Edit(Product ist) {// . . . } public static void Delete(Product ist) {// . . . } public static List<Product> Get() {// . . . }}private void DataForm1_AutoGeneratingField_1(object sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e){ if (e.PropertyName == "Error" || e.PropertyName == "id") { e.Cancel = true; } else if (e.PropertyName == "comp") { e.DataField = new DataFormComboBoxField() { ItemsSource = viewModel.companies, DisplayMemberPath = "name", SelectedValuePath = "id", DataMemberBinding = new Binding("comp.id") { Mode = BindingMode.TwoWay }, Label = "Company" }; } e.DataField.DataMemberBinding.ValidatesOnDataErrors = true; e.DataField.DataMemberBinding.NotifyOnValidationError = true;}Where we sin?
P.S: Sorry for our terrible English, we're from Serbia, and we implemented all CRUD operations with RadDataForm events (EditEnded, AddedNewRecord...).
Thanks in advance!
DMSoft