I've been trying to add a DataGridViewRow to a DataGridView to no avail. I followed the answers here. I can't for the life of me figure out what is wrong with my code!
I'd like to add data using associative keys and not indices :
row.Cells["Column2"].Value = "XYZ";
row.Cells["Column6"].Value = 50.2;
This is my code:
DataGridViewRow dgvr = (dgvSponsor.RowTemplate);
dgvr.Cells["firstName"].Value = fn;
dgvr.Cells["midName"].Value = mi;
dgvr.Cells["lastName"].Value = ln;
dgvr.Cells["suffix"].Value = suffix;
dgvr.Cells["residence"].Value = res;
dgvr.Cells["gender"].Value = radioMale.Checked ? 1 : 2;
I'm getting an ArgumentException
:
I've already set the names for the columns like so:
Why is it still throwing an Exception?