locked
How to Select in Data Table RRS feed

  • Question

  • User809322603 posted

    Hi friends,

    I have a data table which i want to filter using between .But I am not able to apply it properly

    Please help.

    I am trying the below code.

    DataTable selectedTable;
    DataRow[] selectRow;
    string fromConcessionaireid;
    string toConcessionaireid;
    
    
    
    selectRow = finalDT.Select(string.Format("CONCESSIONAIREID between '{0}' and '{1}' ", fromConcessionaireid, toConcessionaireid));
    
      

    Thursday, April 17, 2014 5:25 AM

Answers

  • User1218929252 posted

    You can use a Dataview..

    DataTable selectedTable;
    DataRow[] selectRow;
    string fromConcessionaireid;
    string toConcessionaireid;
    
    DataView dv = new DataView(selectedTable);
    
    dv.RowFilter = string.Format("CONCESSIONAIREID between '{0}' and '{1}' ", fromConcessionaireid, toConcessionaireid);

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 17, 2014 5:42 AM

All replies

  • User1218929252 posted

    You can use a Dataview..

    DataTable selectedTable;
    DataRow[] selectRow;
    string fromConcessionaireid;
    string toConcessionaireid;
    
    DataView dv = new DataView(selectedTable);
    
    dv.RowFilter = string.Format("CONCESSIONAIREID between '{0}' and '{1}' ", fromConcessionaireid, toConcessionaireid);

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 17, 2014 5:42 AM
  • User-488622176 posted
    var query = finalDT.Where(c => !(c.CONCESSIONAIREID >= Convert.ToInt(fromConcessionaireid) && c.CONCESSIONAIREID <= toConcessionaireid));
    var myDataView = query.AsDataView(); // if you want to databind...
    Friday, April 18, 2014 10:20 AM