用DataView,以下from MSDN
以下代码示例创建一个视图,该视图显示所有库存量小于或等于再订购量的产品,这些产品首先按供应商 ID 排序,然后按产品名称排序。[Visual Basic]
Dim prodView As DataView = New DataView(prodDS.Tables("Products"), _
                                        "UnitsInStock <= ReorderLevel", _
                                        "SupplierID, ProductName", _
                                        DataViewRowState.CurrentRows)
[C#]
DataView prodView = new DataView(prodDS.Tables["Products"],
                                 "UnitsInStock <= ReorderLevel",
                                 "SupplierID, ProductName",
                                 DataViewRowState.CurrentRows);

解决方案 »

  1.   

    用XMLDATEDocument将XML的数据转换为DATASET的咯(就是XML-DATASET),
    DataSet ds=new DataSet();
    XmlDataDocument doc=new XmlDataDocument();
    DataView dv=new DataView();
        DataSet ds1=new DataSet(); doc.DataSet.ReadXml("xxx.xml"); ds1=createDataSet(doc,"XXX.XML");
    //createDataSet中,你可以用XPATH进行查询咯,
    showdata1.DataSource=doc.DocumentElement.ChildNodes;
    showdata1.DataSource=ds1;
    showdata1.DataMember=ds1.Tables[0].TableName;
      

  2.   

    jackyrong():
    假如我有一个xml文件结构如下:
    <main>
      <message actiontime="2002-8-15 12:43:21" t="15"/>
      <message actiontime="2002-8-16 12:43:21" t="16"/>
      <message actiontime="2002-8-17 12:43:21" t="17"/>
      <message actiontime="2002-8-18 12:43:21" t="18"/>
    </main>
    怎么样用你的方法把时间在2002-8-27之后的数据找出来,并绑定到一个datalist上,把t的值显示出来,谢谢您的帮助!
      

  3.   

    一个更好的方法,DataSet.Tables["Tablename"].Select(),方法如下:
       DataRow[] myRows;
       DataTable myTable; 
       myTable = DataSet1.Tables[0];
       myRows = myTable.Select("actiontime>=2002-8-17","t",DataViewRowState.CurrentRows);
       for(int i = 0; i < myRows.Length ; i++){
          Response.Write(myRows[i]["id"]);
    }
      

  4.   

    myRows = myTable.Select("actiontime>=2002-8-17","t",DataViewRowState.CurrentRows);
    这句不对?
      

  5.   

    时间用符号##,如下:
    myRows = myTable.Select("actiontime>=#2002-8-17#","t",DataViewRowState.CurrentRows);
      

  6.   

    问题解决,thx,请到下面两个帖子领分!
    http://www.csdn.net/expert/topic/948/948970.xml?temp=.3934137
    http://www.csdn.net/expert/topic/949/949098.xml?temp=.5325891