Click here to Skip to main content
14,668,708 members
Rate this:
Please Sign up or sign in to vote.
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 :(

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

Rate this:
Please Sign up or sign in to vote.

Solution 1

   
Comments
anthp 3-Jun-13 9:30am
   
Hi Prasad,
Thank you , I will go reading
Cheers
Tony
Rate this:
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.
   
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
Rate this:
Please Sign up or sign in to vote.

Solution 3

Thanks all for your help - all working great

cheers

Tony
   

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




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