Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Again a mmCombobox question
Message
From
22/08/2003 12:41:23
Ali Ihsan Turkoolu
Galaksi Bilgisayar A.Þ.
Ankara, Turkey
 
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
00822250
Message ID:
00822664
Views:
17
Sorry, I try but I can't solve.
When I debug, I always get the type of Value object as "System.Data.DataRowView".

Ali ihsan,

>>Although, I added .ToString().
>
>Oops...you're right, I neglected to add .ToString(), in addition, you should also check for the Type of the SelectedValue:
>
>
private void cboCustomers_SelectedIndexChanged(object sender, System.EventArgs e)
>{
>    object Value = this.cboCustomers.SelectedValue;
>    if (Value is String)
>    {
>        this.txtCustomerID.Text = Value.ToString();
>    }
>}
>
>The reason you have to check for the type is because the SelectedIndexChange event fires when the combo box's DisplayMember and ValueMember properties are set at run time, and the type of the SelectedValue is "invalid" at this point. Although some might argue this is "by design", I consider this is a .NET bug!
>
>These properties get set automatically for you by MM .NET. I have tried to reverse the order so I set the combo box BindingSource AFTER setting the DisplayMember and ValueMember properties, but .NET doesn't like that...the combo box doesn't bind properly.
>
>So, long story short, you need to check the type of the value in the SelectedIndexChange event handler.
>
>Regards,
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform