Hi,
I have a dataGridView that is bound to dataset.I have created a add new button for DatagridView. my problem is the studentid that is a primary key column which is already defined in the table. I am struggling to autoincrement the datatable.please review the code below and let me know how to proceed this.
button_click has
dr = ds.Tables[0].NewRow();
dr["firstname"] = "code";
dr["lastname"] = "sss";
dr["grade"] = 45;
dr["studentID"]=dt.PrimaryKey = new DataColumn[] { dt.Columns["studentID"] };//error
ds.Tables[0].Rows.Add(dr);
the error message is unable to cast object of type System.Data.DataColumn[] to type system.Iconvertible.