I'm getting really tire of this error. What object,what reference, what...Sigh... Anyway, what I'm doing here is filling a data grid with data from the database. I'm looking for my record... regardless of whether or not I actually select an item, when I press the search button again (maybe to refine the search params), I get the error about "object reference not set to an instance of an object". It keeps crapping out on the "Pnum" line in the code below:
private void DgPatSrch_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var id = ((DataRowView)DgPatSrch.SelectedItem).Row["Pnum"].ToString();
var name = ((DataRowView)DgPatSrch.SelectedItem).Row["Pname"].ToString();
var dob = ((DataRowView)DgPatSrch.SelectedItem).Row["Dob"].ToString();
TbPatIdReadOnly.Text = id;
TbPatNameReadOnly.Text = name;
TbDobReadOnly.Text = dob;
}
So, how would I fill a data grid, not like what I filled it with, pass new params, and repopulate it? Everything seems to work EXCEPT the repopulate. It almost seems like I need to reinitialize the data grid or clear or refresh... but none of those have worked... Help please!!!