Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 :(

XML
<DataGrid.Columns>
    <DataGridTextColumn Width="200" Header="colS" />
    <DataGridTextColumn Width="200" Header="colA"  />
    <DataGridTextColumn Width="1" Header="colF"   />
</DataGrid.Columns>



C#
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
Updated 3-Jun-13 14:10pm
v2

 
Share this answer
 
Comments
anthp 3-Jun-13 9:30am    
Hi Prasad,
Thank you , I will go reading
Cheers
Tony
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.
 
Share this answer
 
Comments
anthp 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
Thanks all for your help - all working great

cheers

Tony
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900