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

[Solved] Blank ComboBox after code-behind binding?

1 Answer 363 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Todd
Top achievements
Rank 1
Todd asked on 29 Oct 2010, 01:10 AM
I have several combo boxes in a grid.  The combo boxes often (but not always) appear empty until I click on them. Once I click on a combo box, the correct data appears in the combo box.  Whether a combo box appears empty or has correct data seems to be completely random. I DO NOT use a View Model nor do I use MVVM.  The item source for my grid is set at run-time through an observable collection in the code-behind of the view.  The observable collection is filled through a web service, which connects to a SQL server database.  

I know this is not the ideal way to do things, but I don't have time to change to a standard view model system, or a MVVM system.  Refreshing the webpage will completely change which combo boxes are empty.  I do not set the grid item source nor the comboBox item sources at design time.  I set the item sources for the grid and the comboboxes at runtime, using the following:

Grid item source (productVersions is an observable collection) :
uiProductVersions.ItemsSource = productVersions;

ComboBox item source (resources is an observable collection) :
private void uiProductVersions_DataLoaded(object sender, EventArgs e)
    {
        ((GridViewComboBoxColumn)uiProductVersions.Columns["uiOwnerWwid"]).ItemsSource = resources;
    }
private void uiProductVersions_DataLoaded(object sender, EventArgs e)
{
(GridViewComboBoxColumn)uiProductVersions.Columns["uiOwnerWwid"]).ItemsSource=resources;
}

I set the other properties of the combo box at design time:
<telerik:GridViewComboBoxColumn DataMemberBinding="{Binding ownerWwid, Mode=TwoWay}" DisplayMemberPath="name" SelectedValueMemberPath="value" Header="Owner" x:Name="uiOwnerWwid" UniqueName="uiOwnerWwid" />


How can I get the combo boxes of my grid to all show the correct data each time the webpage loads, instead of having random combo boxes showing the correct data, and other combo boxes showing empty data?  Switching to a view model or MVVM system is not an option.

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 29 Oct 2010, 08:14 AM
Hello Todd,

Most probably the reason for this behavior is inappropriate DataMemberBinding setting. You may take a look at this or this forum threads for a reference on the same issue. Still, if none of them helps, I would need more details about you project, more specifically about the ItemsSource-s of the grid and the GridViewComboBoxColumn and the exposed properties in each one of them.
 

Best wishes,
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
Tags
GridView
Asked by
Todd
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or