DataRow newRow=dataTable.NewRow();
newRow["CustomerID"]=txtCustomerID.Text;
newRow["Country"]=txtCountry.Text;
...
dataTable.Rows.Add(newRow);
DataAdapter.Update(myDataSet,"Customers");
Application.DoEvents();
myDataSet.AcceptChanges();
newRow["CustomerID"]=txtCustomerID.Text;
newRow["Country"]=txtCountry.Text;
...
dataTable.Rows.Add(newRow);
DataAdapter.Update(myDataSet,"Customers");
Application.DoEvents();
myDataSet.AcceptChanges();
解决方案 »
- DataGridView
- 数组问题
- 如何控制两个datagridview绑定同一个属性类的问题~~~标题要长~~~~~~~~~~~~~~
- datagridview中的数据导出到pdf中
- 关于取的ID问题
- 谁知道如何使用ftb.imagegallery.aspx获取图片的地址???
- 谁有msdn中文版?
- 用过Infragistics NetAdvantage 2005 Volume 这个.NET控件既高手进来一下
- 哪位能找到.net的MSDN文档下载?请告诉我!
- DataGride里的HyperLinkColumn 如何URL加密?
- 软件开发需要数学知识吗?
- 帮个忙! 菜鸟有个问题! 关于DLL
int newrowIndex= this.dataGrid.CurrentRowIndex+1;
row["编号"]=this.dataGrid.CurrentRowIndex+1;
this.listBox.SelectedIndex=
this.dataGrid.CurrentRowIndex+1;
this.cmDataSet.Tables["CommiteeMan"].Rows.InsertAt(row,newrowIndex);
这样也不行,请各位帮忙
应该是row["编号']这个地方不对
Winform上面是邦定数据库的textbox,下面是一个datagrid也是邦定的,然后我的想法是在下面的Datagrid中选取的行(记录)前或后插入记录,
编号是主键,然后其他数据通过上面帮定的textbox输入
如下是我的代码,思路估计也是错的,望大家指教:
this.cmDataSet.EnforceConstraints=false;
DataRow row = this.cmDataSet.Tables["CommiteeMan"].NewRow();
int newrowIndex= this.dataGrid.CurrentRowIndex+1;
row["编号"]=this.dataGrid.CurrentRowIndex+1;
this.cmDataSet.Tables["CommiteeMan"].Rows.InsertAt(row,newrowIndex);
this.dataGrid.CurrentRowIndex++;
this.cmDataSet.EnforceConstraints=true;
DataRow row = this.cmDataSet.Tables["CommiteeMan"].NewRow();
int newrowIndex= this.dataGrid.CurrentRowIndex;正确顺序为:
int newrowIndex= this.dataGrid.CurrentRowIndex;
DataRow row = this.cmDataSet.Tables["CommiteeMan"].NewRow();