EDN Admin
Well-known member
I am devevloping a Windows Forms application using VS2010, .Net Framework 4.0, VB Powerpack 3.0 and C#. Im using LINQ to Entities for data access. Data source objects have been created for these entities which are used by a form that
I am currently developing. Two bound DataRepeaters have been added to this form in a master-detail configuration. This is my first time using DataRepeaters, so the learning curve has been a bit steep.
The master DataRepeater is successfully controlling which records appear in the related ("child") detail DataRepeater. However, the detail DataRepeater contains two combo boxes that are behaving incorrectly. For my question, I will focus on only
one of these two combo boxes.
So far, I have discovered the following problems with the combo box behavior:
<ol>
When the detail DataRepeater initially displays data, the combo box displays the ValueMember (an ID) instead of the DisplayMember.
When a different item is selected from the dropdown list, the SelectedIndexChanged event is successfully triggered, but the SelectedValue property is null. Consequently, the combo box can not be used to change the stored value behind the control.
</ol>
Im using the ItemCloned event of the DataRepeater to configure the combo box as shown below:
<div style="background-color:white; color:black
<pre> <span style="color:blue private <span style="color:blue void metricsDataRepeater_ItemCloned(<span style="color:blue object sender, Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs e)
{
<span style="color:blue var metricCategories = dc.MetricCategories.OrderBy(m => m.Category);
Control[] foundControls = e.DataRepeaterItem.Controls.Find(<span style="color:#a31515 "metricCategoryIDComboBox", <span style="color:blue false);
ComboBox cmb = (ComboBox)foundControls[0];
cmb.ValueMember = <span style="color:#a31515 "MetricCategoryID";
cmb.DisplayMember = <span style="color:#a31515 "Category";
cmb.DataSource = metricCategories.ToList<MetricCategory>();
}
[/code]
The above code is what allows the combo box to correctly display the data from the lookup table in the dropdown list, but it does not resolve either of the above mentioned problems. I have already searched performed many internet searches and have
come-up empty. I have found one or two kluge work arounds, but nothing that will make the combo boxes behave correctly.
Does anyone have any tips or code samples that will specifically resolve the above problems?
<br/>
View the full article
I am currently developing. Two bound DataRepeaters have been added to this form in a master-detail configuration. This is my first time using DataRepeaters, so the learning curve has been a bit steep.
The master DataRepeater is successfully controlling which records appear in the related ("child") detail DataRepeater. However, the detail DataRepeater contains two combo boxes that are behaving incorrectly. For my question, I will focus on only
one of these two combo boxes.
So far, I have discovered the following problems with the combo box behavior:
<ol>
When the detail DataRepeater initially displays data, the combo box displays the ValueMember (an ID) instead of the DisplayMember.
When a different item is selected from the dropdown list, the SelectedIndexChanged event is successfully triggered, but the SelectedValue property is null. Consequently, the combo box can not be used to change the stored value behind the control.
</ol>
Im using the ItemCloned event of the DataRepeater to configure the combo box as shown below:
<div style="background-color:white; color:black
<pre> <span style="color:blue private <span style="color:blue void metricsDataRepeater_ItemCloned(<span style="color:blue object sender, Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs e)
{
<span style="color:blue var metricCategories = dc.MetricCategories.OrderBy(m => m.Category);
Control[] foundControls = e.DataRepeaterItem.Controls.Find(<span style="color:#a31515 "metricCategoryIDComboBox", <span style="color:blue false);
ComboBox cmb = (ComboBox)foundControls[0];
cmb.ValueMember = <span style="color:#a31515 "MetricCategoryID";
cmb.DisplayMember = <span style="color:#a31515 "Category";
cmb.DataSource = metricCategories.ToList<MetricCategory>();
}
[/code]
The above code is what allows the combo box to correctly display the data from the lookup table in the dropdown list, but it does not resolve either of the above mentioned problems. I have already searched performed many internet searches and have
come-up empty. I have found one or two kluge work arounds, but nothing that will make the combo boxes behave correctly.
Does anyone have any tips or code samples that will specifically resolve the above problems?
<br/>
View the full article