Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to find value in a column of data view
Message
 
 
À
10/08/2012 10:36:56
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01550250
Message ID:
01550293
Vues:
33
>>>>>
>>>>>Sorry, I probably misread what you were binding the combobox to. The important point is that the ComboBox.SelectedItem property returns an Object and you should cast it to the actual type to access the members. If you are using v2 then you will need to change var to the actual type.
>>>>>
>>>>>If you're still stuck let me know the actual type of SelectedItem and I'll try again :-}
>>>>
>>>>Thank you for your reply. I suppose I need to upgrade to the latest version of VS since C# has some new features I could be using. But meanwhile I will use the actual type; this is not a problem.
>>>>
>>>>Since I use .NET very infrequently (even though I designed and wrote this program that I maintain), I am at loss to how cast the object to the actual type. If it does not take too much time for you to give me help, I would appreciate it. But if you are pressed by time, don't feel obligated. I will keep Googling on this question and hopefully will hit the right page.
>>>>Again, thank you.
>>>
>>>In my attempt:
var value = ((System.Data.DataRowView)ddlPriority.SelectedItem).Row["NUM_DAYS"];
I'm casting to the DataRowView type. Simply substitute your type within the brackets (and also use the type instead of var). Hopefully that will give you something to drill into to find what you need......
>>>
>>>If you're thinking of upgrading then maybe you should wait for VS2012 / Net 4.5 which should be available soon (I'm using the RC)
>>>,
>>
>>Upgrading to the latest version of VS is not super urgent so I will wait for VS2012 SP2 <g>.
>>
>>What confuses me in your expresion (and it is just me) is that you don't have anywhere the name of the data view but rather the name of the combo/drop down (ddlPriority is the name of the combo control). I few examples I found, online, when describing the use of DataRowView seem to always have the name of the Data View. I will keep looking ...
>
>
>What *is* the type of this.ddlPriority.SelectedValue ? (We may both remain confused until I know that :-})

The type of ddlPriority.SelectedValue is String (PRIORITY). But I don't see where I can specify this type. Thank you again for being patient with me :)
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform