Hello:
I have a bound DataGridView that I need to add data to. As a result, I cannot just add a row. I just want to add a row, and I suppose I have to figure out field 1 (the PK number), and 2 (the Job number from the Job Table. The table I'm speaking of is the JobDetail table, so everything is about that job.
I have seen a few examples, but they just don't work well.
In this case:
I get a System.InvalidCastExxception error on the first line. 'Unable to cast object of type 'System.Windows.Forms.BindingSource' to type 'System.Data.DataTable'.'
I just want to add a new record with blank values, and specify the two dependent values for the data relationship.
Thanks,
I have a bound DataGridView that I need to add data to. As a result, I cannot just add a row. I just want to add a row, and I suppose I have to figure out field 1 (the PK number), and 2 (the Job number from the Job Table. The table I'm speaking of is the JobDetail table, so everything is about that job.
I have seen a few examples, but they just don't work well.
In this case:
C#:
DataTable dt = (DataTable)dgvJobDetail.DataSource;
DataRow dr_Add = dt.NewRow();
dr_Add[0] = "0000";
dr_Add[1] = "1111";
dt.Rows.Add(dr_Add);
dt.AcceptChanges();
dgvJobDetail.DataSource = dt;
I get a System.InvalidCastExxception error on the first line. 'Unable to cast object of type 'System.Windows.Forms.BindingSource' to type 'System.Data.DataTable'.'
I just want to add a new record with blank values, and specify the two dependent values for the data relationship.
Thanks,