Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
275
DataPresenterBase.SelectedItems to System.Data.DataTable
posted

I have a xamDataGrid that has a System.Data.DataView binded to it.  When the user clicks on a button I want to create a System.Data.DataTable that contains all of the selected records in the grid.  What would be the most efficient way to do this?

 Thank you,
Mike

Parents
  • 8576
    Verified Answer
    Offline posted
    Hi Mike -
     
    The xamDataGrid allows 3 types of objects to be selected: Records, Fields (i.e., columns) and Cells.  The xamDataGrid exposes a SelectedItems property which returns a SelectedItemHolder that exposes 3 collection type properties: Cells, Fields and Records.  These collections contain entries for the selected items (if any) in each category. 
     
    In your Button click event handler you could iterate through myDataGrid.SelectedItems.Records and build your DataTable.
     
    BTW - the xamDataGrid also exposes a SelectedItemsChanged event that you could listen to to rebuild your DataTable as the user changes the selection.
     
    Joe
     
Reply Children
No Data