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();
}

解决方案 »

  1.   

    Dv.RowFilter="a like '%a%'";
      

  2.   

    1,DataSet.Select("SQL Where 语句")
    2,DataView.RowFilter = "SQL Where 语句";
      

  3.   

    DataView.RowFilter 属性:   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";
      

  4.   

    [C#] 
    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");
    }
      

  5.   

    java.Net厉害^_^
    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;
      

  6.   

    ((DataTable)this.DataGrid1.DataSource).DefaultView.RowFilter = "过滤条件";
      

  7.   

    因为DataGrid绑定的是DataView,
    楼主使用DataView的RowFilter属性进行过滤就行了。
    如:
    DataView dv = (DataView)this.dataGrid1.DataSource;
    dv .RowFilter="id like '%11%'";