<DataGrid x:Name="gridTable1"> <DataGrid.ItemContainerStyle> <Style TargetType="DataGridRow"> <EventSetter Event="MouseUp" Handler="dataGridRow_MouseUp"/> </Style> </DataGrid.ItemContainerStyle> </DataGrid>
private void dataGridRow_MouseUp(object sender, MouseButtonEventArgs e) { DataGridRow dgr = sender as DataGridRow; DataRowView drv = dgr.DataContext as DataRowView; //This error: Object reference not set to an instance of an object string requestId = drv.Row["RequestID"].ToString(); DataTable dt = new DataTable(); dt = db.MySelect("select RequestID from Requests where RequestID='" + requestId + "'"); gridTable2.ItemsSource = dt.DefaultView; }
sender
as
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)