Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to customize datatable.Select

how to customize datatable.Select

Scheduled Pinned Locked Moved C#
csharptutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jojoba2011
    wrote on last edited by
    #1

    I am writing a windows desktop application in C# 2008 and i wanna to have select for datatable :

    IEnumerable<string> idsInA = dtd.AsEnumerable().Select(row => (string)row["ID"]);

    it filters only on one row (ex.ID) but the thing i wanna is for three rows (ex:ID , Title , Path) Ho i can do that ?

    R 1 Reply Last reply
    0
    • J jojoba2011

      I am writing a windows desktop application in C# 2008 and i wanna to have select for datatable :

      IEnumerable<string> idsInA = dtd.AsEnumerable().Select(row => (string)row["ID"]);

      it filters only on one row (ex.ID) but the thing i wanna is for three rows (ex:ID , Title , Path) Ho i can do that ?

      R Offline
      R Offline
      Ron Beyer
      wrote on last edited by
      #2

      IEnumerable idsInA =
      (from row in dtd
      where row["ID"] = idFilter && row["Title"] = titleFilter && row["Path"] = pathFilter
      select row["ID"]).AsEnumerable();

      But this only returns one column, if you want all the columns, you would use something like this:

      var rowsInA =
      (from row in dtd
      where row["ID"] = idFilter && row["Title"] = titleFilter && row["Path"] = pathFilter
      select row);

      and then rowsInA is an IEnumerable that contains the row objects.

      J 1 Reply Last reply
      0
      • R Ron Beyer

        IEnumerable idsInA =
        (from row in dtd
        where row["ID"] = idFilter && row["Title"] = titleFilter && row["Path"] = pathFilter
        select row["ID"]).AsEnumerable();

        But this only returns one column, if you want all the columns, you would use something like this:

        var rowsInA =
        (from row in dtd
        where row["ID"] = idFilter && row["Title"] = titleFilter && row["Path"] = pathFilter
        select row);

        and then rowsInA is an IEnumerable that contains the row objects.

        J Offline
        J Offline
        jojoba2011
        wrote on last edited by
        #3

        thanks in advnaced! But i wanna to return all cells of my datatable ! (Not filter some !!! [No where])

        R 1 Reply Last reply
        0
        • J jojoba2011

          thanks in advnaced! But i wanna to return all cells of my datatable ! (Not filter some !!! [No where])

          R Offline
          R Offline
          Ron Beyer
          wrote on last edited by
          #4

          Then just remove the where part of the second example I gave.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups