Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF DataGrid
Hi
I have my code as follows but when i click on an item in datagrid 1 it only brings up a blank row on datagrid2 - no text Frown | :(
 
<DataGrid.Columns>
    <DataGridTextColumn Width="200" Header="colS" />
    <DataGridTextColumn Width="200" Header="colA"  />
    <DataGridTextColumn Width="1" Header="colF"   />
</DataGrid.Columns>
 

private void SongDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
     if (SongDataGrid.SelectedIndex >= 0)
    {
 
        var i = SongDataGrid.SelectedIndex.ToString();
        System.Data.DataRowView lbi = (System.Data.DataRowView)SongDataGrid.SelectedValue;
        var SongName = (lbi.Row[0].ToString());
        var ArtistName = (lbi.Row[1].ToString());
        var FileLocation = (lbi.Row[2].ToString());
        myPlayList.Items.Add(new { colS = SongName, colA = ArtistName, colF = FileLocation });
 

cheers
 
Tony
Posted 3-Jun-13 1:32am
anthp878
Edited 3-Jun-13 15:10pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
anthp at 3-Jun-13 9:30am
   
Hi Prasad,
Thank you , I will go reading
Cheers
Tony
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi ,
 
you can achieve the functionality as follows.
 
1. define the new DataTable with columns of first datagrid.
 
2. in the selected item change event of first datagrid1 ,bind the each column data to already declared datatble.
 
3. Bind the datatable to second datagrid.
 
is this help full, or do you want any help?
 
Regards,
Kiran.
  Permalink  
Comments
anthp at 3-Jun-13 9:29am
   
Hi Kiran
Thank you, I will give a try and ask for more help if I need it
Cheers
Tony
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Thanks all for your help - all working great
 
cheers
 
Tony
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 4 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100