我想在 Datagrid 中添加新行但有错误。
错误:当控件绑定数据时,无法以编程方式将行添加到 DataGridView 的行集合。
row = new string[] { "0", "1", hesab_nomresi,soyad,ad,ataadi,vesiqe,teskilat_kodu,tevellud,nomre,cins };
kartsifarishiGridView.Rows.Add(elaveEtme.row);
AllowUserToAddRow = false;
数据源:(从作者的评论中添加)
string sqlSorgu = "SELECT" + " customer.id, + " IIf (customer.cins = 'M','Kişi','Qadın') AS Cins " + " FROM customer ORDER BY customer.id ASC";
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(sqlSorgu, Program.esas.bazayaQosul);
DataTable dataTable = new DataTable();
set = new DataSet();
set.Tables.Add(dataTable);
dataAdapter.Fill(dataTable);
kartsifarishiGridView.DataSource = dataTable;