none
how to use filter criteria in datatable RRS feed

  • Question

  •  

    hi,

     

    I have a  dataset generated by .net code. I need to get the table values from the

    xml file using a filter criteria over the dataset.

     

    i also tried it by read dataset and in that identify the table using datatable concept.

     

    i dont know how to filter the values in the datatable. please help me in applying filter criteria over the data table.

     

    eg:

    i need to filter it by particular id(column value.) ie ., i have table with attributes as

    TaskID

    TaskName

    ...

    I want the values of a particular TaskID.

     

    pl help me  on this its urgent.

     

     

     

     

    thanks in advance

     

    Sridhar

    Tuesday, July 3, 2007 12:41 PM

All replies

  • Create a DataView and set its RowFilter.  There are a bunch of different ways to do this:

        string filter = "TaskID = " + taskID.ToString();
        DataView dv = myDataTable.DefaultView;
        dv.RowFilter = filter;

    or, using the constructor:

        DataView dv = new DataView(myDataTable, filter);


    Look under "Sorting and Filtering Data Using a DataView" in the help.
    Tuesday, July 3, 2007 10:23 PM
  • It'd help if you could tell me a little more about the specifics. If I understand you correctly, you need to filter a datatable based on some criteria?  If so, then you can use the DefaultView.RowFilter property of the given datatable and filter there.  You may also be able to use DataTable.Select . 

     

    That's if you're using it as  a DataTable.  From your question though, it also sounds like you may actually want to query the XML for those attributes.  Before getting into it too much, are you primarily working with XML or do you want to use a DataTable?  The approach will be markedly different (forunately both are simple) depending on which you need to do.

     

    Cheers,

     

    Bill

    Wednesday, July 4, 2007 1:38 AM