Anyone have an idea why the line FullNameTextBox.Text = row[0].ToString(); causes a NullReferenceException whenever dataTable.Clear() is called? I can't use TableAdapter.Fill() because of this. The ta.Insert would work fine until you click on a row on the datagrid. Changing FullNameTextBox into another text box that's not within the ta.Insert line doesn't work either.
private DataRowView row;
private byte[] xByte;
TestDataSetTableAdapters.TestingTableTableAdapter ta = new TestDataSetTableAdapters.TestingTableTableAdapter();
TestDataSet ts = new TestDataSet();
private void AddButton_Click(object sender, RoutedEventArgs e)
{
ta.Insert(FullNameTextBox.Text, xByte, ColumnTwoTextBox.Text, ColumnThreeTextBox.Text);
ta.Fill(ts.TestingTable);
}
private void TestGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
row = (DataRowView)TestGrid.SelectedItem;
FullNameTextBox.Text = row[0].ToString(); //this would cause the exception removing this line would make the Add Button work even when the SelectionChanged event has been triggered
}