I'm a bit new to the RadControls, and C# in general, so bear with me if the trouble I am facing is due to some terribad implementation. Anyway, here is the problem.
I have a single, form that has a number of radGridViews on it. Most of the grids are very simple lists with a schema that consists of not much more than an 'ID'{int} and a 'Name'{string}. I also have one master grid with a number of GridViewComboBoxColums that reference the aforementioned lists. I'm using entity framework models for the datasources, which I assign using the below
Note: The RadGridViews and GridViewComboBoxColums are sharing the same DataSources, a.k.a. I have a grid for status's and a combo box on another grid that both use the statusBindingSource.
When I start the application it populates the grids, columns, and combo boxes from the database; no problem is had. If I then add a row, new value, to one of the Grids that value will show up in the corresponding combobox, but if I select the new value, which apears correctly in the drop down list, the cell will be blank. The correct value is selected, and it submits correctly to the database/model, but it does not display. I suspect that is has something to do with the DisplayMember, but I'm not sure. If I restart the program, and the form is recreated, the new values that were gotten from the database display correctly. What I would like is for the new values to display in their cells, without having to close and restart the form application.
I warn that most of the grid creation was done with the designer, so I am hesitant to post too much of that generated code, but I'll try and get the important bits in here
I hope I explained my problem thorougly, if not please tell me so that I can elaborate on anything important that I missed. Thank you in advance for the help.
-Joel
EDIT: Quite interstingly, if I right click and clear the value on the cell it displays correctly.
I have a single, form that has a number of radGridViews on it. Most of the grids are very simple lists with a schema that consists of not much more than an 'ID'{int} and a 'Name'{string}. I also have one master grid with a number of GridViewComboBoxColums that reference the aforementioned lists. I'm using entity framework models for the datasources, which I assign using the below
VendorManagerEntities context =
new
VendorManagerEntities();
protected
override
void
OnLoad(EventArgs e)
{
base
.OnLoad(e);
contactBindingSource.DataSource = context.Contacts;
statusBindingSource.DataSource = context.Status;
priorityBindingSource.DataSource = context.Priorities;
categoryBindingSource.DataSource = context.Categories;
}
When I start the application it populates the grids, columns, and combo boxes from the database; no problem is had. If I then add a row, new value, to one of the Grids that value will show up in the corresponding combobox, but if I select the new value, which apears correctly in the drop down list, the cell will be blank. The correct value is selected, and it submits correctly to the database/model, but it does not display. I suspect that is has something to do with the DisplayMember, but I'm not sure. If I restart the program, and the form is recreated, the new values that were gotten from the database display correctly. What I would like is for the new values to display in their cells, without having to close and restart the form application.
I warn that most of the grid creation was done with the designer, so I am hesitant to post too much of that generated code, but I'll try and get the important bits in here
private
void
InitializeComponent()
{
this
.radGrid_Contacts =
new
Telerik.WinControls.UI.RadGridView();
// Contacts is "supergrid" that has a ton of combo boxes
this
.contactBindingSource =
new
System.Windows.Forms.BindingSource(
this
.components);
((System.ComponentModel.ISupportInitialize)(
this
.buyerBindingSource)).BeginInit();
this
.radGrid_Statuses =
new
Telerik.WinControls.UI.RadGridView();
// Status is a simple list, every status wants to some day be part of a combobox
this
.statusBindingSource =
new
System.Windows.Forms.BindingSource(
this
.components);
((System.ComponentModel.ISupportInitialize)(
this
.statusBindingSource)).BeginInit();
// ...
//
// Contact Rad Grid
//
this
.radGrid_Contacts.MasterTemplate.AutoGenerateColumns =
false
;
this
.radGrid_Contacts.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
gridViewDecimalColumn1.DataType =
typeof
(
int
);
gridViewDecimalColumn1.EnableExpressionEditor =
false
;
gridViewDecimalColumn1.FieldName =
"ID"
;
gridViewDecimalColumn1.HeaderText =
"ID"
;
gridViewDecimalColumn1.IsAutoGenerated =
true
;
gridViewDecimalColumn1.Name =
"ID"
;
gridViewDecimalColumn1.ReadOnly =
true
;
gridViewComboBoxColumn4.DataSource =
this
.statusBindingSource;
gridViewComboBoxColumn4.DataType =
typeof
(
int
);
gridViewComboBoxColumn4.DisplayMember =
"Name"
;
gridViewComboBoxColumn4.EnableExpressionEditor =
false
;
gridViewComboBoxColumn4.FieldName =
"Status_ID"
;
gridViewComboBoxColumn4.HeaderText =
"Status"
;
gridViewComboBoxColumn4.Name =
"Status_ID"
;
gridViewComboBoxColumn4.ValueMember =
"ID"
;
gridViewComboBoxColumn4.Width = 129;
this
.radGrid_Contacts.MasterTemplate.Columns.AddRange(
new
Telerik.WinControls.UI.GridViewDataColumn[] {
gridViewDecimalColumn1,
gridViewComboBoxColumn4,
gridViewCommandColumn1});
this
.radGrid_Contacts.MasterTemplate.DataSource =
this
.contactBindingSource;
this
.radGrid_Contacts.MasterTemplate.DataSource =
this
.contactBindingSource;
this
.contactBindingSource.DataSource =
typeof
(VendorManager.Contact);
//
// radGrid_Statuses
//
gridViewDecimalColumn6.DataType =
typeof
(
int
);
gridViewDecimalColumn6.EnableExpressionEditor =
false
;
gridViewDecimalColumn6.FieldName =
"ID"
;
gridViewDecimalColumn6.HeaderText =
"ID"
;
gridViewDecimalColumn6.IsAutoGenerated =
true
;
gridViewDecimalColumn6.IsVisible =
false
;
gridViewDecimalColumn6.Name =
"ID"
;
gridViewDecimalColumn6.Width = 301;
gridViewTextBoxColumn23.EnableExpressionEditor =
false
;
gridViewTextBoxColumn23.FieldName =
"Name"
;
gridViewTextBoxColumn23.HeaderText =
"Status Name"
;
gridViewTextBoxColumn23.IsAutoGenerated =
true
;
gridViewTextBoxColumn23.Name =
"Name"
;
gridViewTextBoxColumn23.Width = 909;
gridViewTextBoxColumn24.DataType =
typeof
(VendorManager.TrackableCollection<VendorManager.Contact>);
gridViewTextBoxColumn24.EnableExpressionEditor =
false
;
gridViewTextBoxColumn24.FieldName =
"Contacts"
;
gridViewTextBoxColumn24.HeaderText =
"Contacts"
;
gridViewTextBoxColumn24.IsAutoGenerated =
true
;
gridViewTextBoxColumn24.IsVisible =
false
;
gridViewTextBoxColumn24.Name =
"Contacts"
;
gridViewTextBoxColumn24.Width = 151;
this
.radGrid_Statuses.MasterTemplate.Columns.AddRange(
new
Telerik.WinControls.UI.GridViewDataColumn[] {
gridViewDecimalColumn6,
gridViewTextBoxColumn23,
gridViewTextBoxColumn24,
gridViewTextBoxColumn25});
this
.radGrid_Statuses.MasterTemplate.DataSource =
this
.statusBindingSource;
this
.radGrid_Statuses.Name =
"radGrid_Statuses"
;
}
I hope I explained my problem thorougly, if not please tell me so that I can elaborate on anything important that I missed. Thank you in advance for the help.
-Joel
EDIT: Quite interstingly, if I right click and clear the value on the cell it displays correctly.