Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Again a mmCombobox question
Message
De
22/08/2003 12:41:23
Ali Ihsan Turkoolu
Galaksi Bilgisayar A.Þ.
Ankara, Turquie
 
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
00822250
Message ID:
00822664
Vues:
18
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,
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform