private void BindData()
{
Sql="select * from BookList";
SqlConnection conn=new SqlConnection("server=localhost;database=WroxBooks;uid=sa;pwd=");
SqlDataAdapter adp=new SqlDataAdapter(Sql,conn);
conn.Open();
DataSet ds=new DataSet();
adp.Fill(ds,"books");
DataView dv=ds.Tables["books"].DefaultView;
dv.RowFilter=FindString;
DataGrid1.DataSource=dv;
DataGrid1.DataBind();
conn.Close();
}
{
Sql="select * from BookList";
SqlConnection conn=new SqlConnection("server=localhost;database=WroxBooks;uid=sa;pwd=");
SqlDataAdapter adp=new SqlDataAdapter(Sql,conn);
conn.Open();
DataSet ds=new DataSet();
adp.Fill(ds,"books");
DataView dv=ds.Tables["books"].DefaultView;
dv.RowFilter=FindString;
DataGrid1.DataSource=dv;
DataGrid1.DataBind();
conn.Close();
}
解决方案 »
- 为啥“System.Configuration.ConfigurationSettings”并不包含“appSettings”的定义
- FileStream的问题,如何将生成的字节流还原成原文件?
- 请问自动提取Tag算法的实现
- C#画图板问题
- C# 中后台到数据库中查询数据前台的指针变成沙漏型?????如何实现!!!求各位大虾帮帮偶!!!
- C#程序狂消耗资源,写出的程序有竞争性吗?
- 急人啊!winform模式下,sql2K,水晶报表9总是提示连接登陆?为什么啊?
- 新手求助关于Windows Forms 的问题
- 配置的问题很好拿分的
- 水晶报表中显示电子签名如何实现?
- 请帮忙 新下载的SDK不可用,急
- winform程序中父窗体显示标题时间等载要信息
2,DataView.RowFilter = "SQL Where 语句";
dv.Table = DataSet1.Tables["Suppliers"];
dv.AllowDelete = true;
dv.AllowEdit = true;
dv.AllowNew = true;
dv.RowFilter = "City = 'Berlin'";
dv.RowStateFilter = DataViewRowState.ModifiedCurrent;
dv.Sort = "CompanyName DESC";
private void MakeDataView()
{
DataView dv = new DataView(); dv.Table = DataSet1.Tables["Suppliers"];
dv.AllowDelete = true;
dv.AllowEdit = true;
dv.AllowNew = true;
dv.RowFilter = "City = 'Berlin'";
dv.RowStateFilter = DataViewRowState.ModifiedCurrent;
dv.Sort = "CompanyName DESC";
// Simple bind to a TextBox control
Text1.DataBindings.Add("Text", dv, "CompanyName");
}
System.Data.DataRowView drCurrent;
System.Data.DataView dvNew; dvNew = new System.Data.DataView(); //retrieve the selected row in lbOrders
drCurrent = (System.Data.DataRowView)this.lbClients.SelectedItem;
//configure the dataview
dvNew.Table = this.dsMaster1.OrderTotals;
dvNew.RowFilter = "CustomerID = '" + drCurrent[0] + "'"; //rebind the datagrid
this.dgOrders.DataSource = dvNew;
楼主使用DataView的RowFilter属性进行过滤就行了。
如:
DataView dv = (DataView)this.dataGrid1.DataSource;
dv .RowFilter="id like '%11%'";