Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SelectedValue from a ListView control...
Message
De
20/06/2008 13:40:37
 
 
À
20/06/2008 13:03:13
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Divers
Thread ID:
01325801
Message ID:
01325822
Vues:
11
>In another post, I had asked:
>
>"Once the user clicks on a row in the ListView, how do I get the key value of the customer ID they clicked on so I can call another Linq query to pull up further details or child records, etc?"
>
>Well, I think I found it...
>
>You need to set SelectedValuePath on the ListView to the property of the Customer ID field and then point the SelectionChanged event to a method to, where you can then read the selected Customer ID from the SelectedValue property.
>
>It worsk at least. Maybe there's a better way?
>
>However, how can I receive a reference to the calling ListView in the called SelectionChanged method, so that I do not have to hard-code the "lv2" object reference. That way my method could be used by other ListViews instead of being hard-coded to just the one.
>
>XAML:
>
>
>        <ListView Name="lv2" HorizontalContentAlignment="Stretch" ScrollViewer.VerticalScrollBarVisibility="Visible"
>                       SelectedValuePath="custno" SelectionChanged="CustomerItemSelected">
>
>
>
>Code-Behind:
>
>        private void CustomerItemSelected(object sender, SelectionChangedEventArgs e)
>        {
>            var SelectedCustomerID=lv2.SelectedValue;
>
>            ... more code here ...
>        }
>
Ya that should work.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform