如何在Datagridview上查询? [英] How to query on a Datagridview?
本文介绍了如何在Datagridview上查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想查询一个datagridview.
谁能告诉我该怎么做?
在此先谢谢您.
i want to query over a datagridview.
Can anyone please tell me how to do this?
Thanks in advance.
推荐答案
不确定您的要求,看看是否有帮助:
http://stackoverflow.com/questions/308085/how-to-query- a-datagridview-using-linq [ ^ ]
Not sure about your requirement, see if this helps:
http://stackoverflow.com/questions/308085/how-to-query-a-datagridview-using-linq[^]
要绑定网格,可以使用Datasource和Databind()方法.
您可以使用以下方法将查询绑定到Grid中.
for binding the grid you can use Datasource and Databind() method.
you can use following things to bind your query in Grid.
string s = "select fileds from table name";
SqlDataAdapter ad = new SqlDataAdapter(s,connection object);
DataSet ds = new DataSet();
ad.Fill(ds);
if (ds.Tables[0].Rows.Count != 0)
{
gridview1.datasource=ds;
gridview1.databind();
}
希望这对您有所帮助,否则请发布.
hope this will help you, if not please Post it.
感谢Mits Machhi的宝贵意见.
我已经尝试过Dataview并解决了这个问题.
请在下面查看以下内容:
Thanks Mits Machhi for your valuable comment.
I have tried Dataview and solved this issue.
Please chek this Below:
string Name = "Adrian";
DataView dv = new DataView(dt);
dv.RowFilter = "Name=''" + Name + "''";
dataGridView1.DataSource = dv;
这篇关于如何在Datagridview上查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文