I have a DataSet that contains values returned by my WCF function, as below:
DataSet ds = IserviceClient.FunctionMe(dcClient, dcBook);
#region show to dgv_item
DataTable dt1 = ds.Tables[0];
DataRow dr1;
int rc = dt1.Rows.Count;
clsMessageBoxes.ShowInfo(rc.ToString()); // Here show the number of row, so far the row is show the right value
//from here how to pass the row in that datatable to my datagridview? i
for (int i = 0; i < rc; i++)
{
dr1 = dt1.Rows[i];
dgv_item.Rows.Add();
dgv_item.Rows[i].Cells["dgvc_no"].Value = dr1["cnNo"].ToString();
dgv_item.Rows[i].Cells["dgvc_ID"].Value = dr1["cnID"].ToString();
dgv_item.Rows[i].Cells["dgvc_Name"].Value = dr1["cnName"].ToString();
}
Using this, I get the error
Rows cannot be programmatically added to datagridview's rows collection when the control is data-bound
Why do I get this, and how can I resolve it?