Retrieve data in code behind from wpf radGrid binded with Multiple collections

1 posts, 0 answers
  1. CQT
    CQT avatar
    21 posts
    Member since:
    May 2011

    Posted 17 Dec 2012 Link to this post

    In my application I'm trying to get data from a RadGridView in my code behind. Everything is ok if I bind the grid directly from entity data model with just a table, because this code works fine:


    Dim idordine As String = DirectCast(testGrid.SelectedItem, Orders).OrderID

    In my application I binded my grid with a linq query and my testgrid(radgrid) correctly shows results.
    This is a linq query like the one in my project, used to bind my radgrid:

    Dim query = From employee In employees Join order In orders On employee.EmployeeID = order.EmployeeID
    Select New With { _
        .EmployeeName = employee.LastName, _
        .OrderName = order.ShipName, _
        .OrderDate = order.OrderDate _
    testGrid.ItemsSource = query
            Me.Griglia.ItemsSource = qry

    My problem raises in code behind when I try to retrieve data of the selected row of my testgrid after a double-click event.
    Using the first method I have to assign a type for the directcast, but in case of binding with the query I have no idea of what kind of object to put instead of Orders type.

    Any suggestion?


Back to Top