datagridview更新 [英] datagridview update

查看:141
本文介绍了datagridview更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个datagridview的源是一个datatable。有订单和食品名称列。我在这个datagridview中插入新值并从表中删除。当我选择一行并删除它,所选的颜色移动到顶部,如果我想要删除一个订单相同的食物,我必须每次重新提交。如何解决这个问题?
通过从sql插入或删除后更新datagridview的方式,像这样;

  ds.Clear() ; 
da.Fill(ds);
dataGridView2.DataSource = ds.Tables [0];

da和ds定义如下:

  da = new SqlDataAdapter(sqlcommand); 
ds = new DataSet();


解决方案

我找到答案。
这里是链接


I have a datagridview whose source is a datatable. There are orders and food names columns. I insert new values into the this datagridview and delete from the table. when I select one row and delete it, selected color moves to the top, and if I want to delete one more order for same food, I have to reclick it each time. How can I solve this problem? by the way I update the datagridview after inserting or deleting from sql, like this;

ds.Clear();
da.Fill(ds);
dataGridView2.DataSource = ds.Tables[0];

da and ds is defined like this;

 da = new SqlDataAdapter(sqlcommand);
 ds = new DataSet();

解决方案

I found the answer. Here is the link

这篇关于datagridview更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆