Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SelectedValue from a ListView control...
Message
From
20/06/2008 13:40:37
 
 
To
20/06/2008 13:03:13
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Miscellaneous
Thread ID:
01325801
Message ID:
01325822
Views:
9
>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.
Previous
Reply
Map
View

Click here to load this message in the networking platform