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
515
Accessing column values from selected row in xamGrid
posted

Hello,

I have a xamGrid that I have successfully binded data from the DB. Now I wish to allow users to delete the selected rows. I have the code deleting the selected row from the grid, but need to get the value from a hidden column within the grid to pass to my delete method to delete the row from the DB. How do I get the selected row column value from the code below?

xaml:

<

 

 

ig:XamGrid x:Name="dataGrid" AutoGenerateColumns="false" ColumnWidth="*" Grid.Row="2" >

 

 

 

<ig:TextColumn Key="PivotViewID" Visibility="Collapsed">

<ig:TextColumn.HeaderTemplate>

 

 

 

<DataTemplate>

 

 

 

<TextBlock Text="PivotViewID" />

 

 

 

</DataTemplate>

 

 

 

</ig:TextColumn.HeaderTemplate>

 

 

 

</ig:TextColumn>

code:

void

 

 

Deleteok_Click(object sender, RoutedEventArgs e)

{

 

 

foreach (Row selectedRow in dataGrid.SelectionSettings.SelectedRows)

{

dataGrid.Rows.Remove(selectedRow);

 

 

var proxy = new WcfServiceReference.Service1Client("BasicHttpBinding_IService1");

proxy.DeletePivotViewsCompleted +=

 

new EventHandler<PivotGrid.WcfServiceReference.DeletePivotViewsCompletedEventArgs>(proxy_DeletePivotViewCompleted);

proxy.DeletePivotViewsAsync(2);

 

//selectedRow PivotViewID ???

}

 

 

this.winDeleteMB.Close();

}

  • 21382
    Suggested Answer
    posted

    To get a value from the row you can just access the .Cells collection off the Row object

     

    row.Cells[columnKey].Value

     

    Or even better access the Data off the row, as this is your real data object, and get the value directly off this

     

    MyObject myObj = (MyObject) row.Data;