开发者

How can I obtain the group of "dirty" rows or cells from a DataGridview?

I am working with a DataGridView filled up from a view in my database.

Being a view (maybe I'm wrong) I can't use the TableAdapter.Update() method so I need to know t开发者_C百科he altered cells from the DataGridView so I can update the values in their respective tables programatically.

Can you help me?


You are able to update Views http://msdn.microsoft.com/en-us/library/aa214068(v=SQL.80).aspx

You can also get the edited rows by called DataTable.GetChanges()


A DataGridView is only a transforming layer above the bounded DataTable. All changes applied to the view are directly materialized in the underlying DataTable. You can use the .DataSource property of your view to get a reference for this DataTable.

You have to create a DataAdapter with the appropriate SqlCommand objects for insert, update and delete.

After doing so you can use the DataAdapter.Update(DataTable table) method to apply all changes to the database.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜