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. Web Development
  3. ASP.NET
  4. datatable.select("dintinct columnName");

datatable.select("dintinct columnName");

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netquestion
9 Posts 5 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.
  • S Offline
    S Offline
    S Aijaz
    wrote on last edited by
    #1

    i want to get distinct values of a column in datatable in asp.net. is it possible and how? thanks

    P B H K 4 Replies Last reply
    0
    • S S Aijaz

      i want to get distinct values of a column in datatable in asp.net. is it possible and how? thanks

      P Offline
      P Offline
      padmanabhan N
      wrote on last edited by
      #2

      much clearly explanation would help our experts to give accurate answer.... :rolleyes:

      Padmanabhan My Articles[^]

      S 1 Reply Last reply
      0
      • P padmanabhan N

        much clearly explanation would help our experts to give accurate answer.... :rolleyes:

        Padmanabhan My Articles[^]

        S Offline
        S Offline
        S Aijaz
        wrote on last edited by
        #3

        i have a datatable "TableA" with columns CompanyName EmployeeName EmployeeSalary CompanyName gets repeated in the datatable i want company name in some other datatable say "TableB" and company name should be only once in the column. i want to run query on TableA.Select("Query"); to get unique CompanyName and add these rows to TableB. All i know but wt i nyd to know is wt shd be d query for it. i tries select distinct CompanyName but it thorows an exception

        1 Reply Last reply
        0
        • S S Aijaz

          i want to get distinct values of a column in datatable in asp.net. is it possible and how? thanks

          B Offline
          B Offline
          Baran M
          wrote on last edited by
          #4

          Please try this [^]

          Education is not a way to escape poverty — it is a way of fighting it.

          1 Reply Last reply
          0
          • S S Aijaz

            i want to get distinct values of a column in datatable in asp.net. is it possible and how? thanks

            H Offline
            H Offline
            himanshu2561
            wrote on last edited by
            #5

            If you are using .net framework 3.5 then use LINQ as follows

            var query = (from c in dt.AsEnumerable() select new { FirstName = c.Field<string>("FirstName"), LastName = c.Field<string>("LastName") }).Distinct() ;

            It will give you distinct values.

            himanshu

            S 1 Reply Last reply
            0
            • H himanshu2561

              If you are using .net framework 3.5 then use LINQ as follows

              var query = (from c in dt.AsEnumerable() select new { FirstName = c.Field<string>("FirstName"), LastName = c.Field<string>("LastName") }).Distinct() ;

              It will give you distinct values.

              himanshu

              S Offline
              S Offline
              S Aijaz
              wrote on last edited by
              #6

              im working on ADO.net not LINQ

              H 1 Reply Last reply
              0
              • S S Aijaz

                im working on ADO.net not LINQ

                H Offline
                H Offline
                himanshu2561
                wrote on last edited by
                #7

                Hi Aijaz, But if you are working on framework 3.5 then you can use the code i have posted above. If not then you might be need to create dataview and then filter rows from there.

                himanshu

                S 1 Reply Last reply
                0
                • H himanshu2561

                  Hi Aijaz, But if you are working on framework 3.5 then you can use the code i have posted above. If not then you might be need to create dataview and then filter rows from there.

                  himanshu

                  S Offline
                  S Offline
                  S Aijaz
                  wrote on last edited by
                  #8

                  thnku himanshu it worked

                  1 Reply Last reply
                  0
                  • S S Aijaz

                    i want to get distinct values of a column in datatable in asp.net. is it possible and how? thanks

                    K Offline
                    K Offline
                    Kaushal Arora
                    wrote on last edited by
                    #9

                    You can try hashtables for doing this. But the best way is to change the display at runtime by merging the cells in gridview. You can have a look at this: http://forums.asp.net/p/1053747/1494505.aspx[^] Regards, Kaushal Arora Mark as Answer if it Solved Your Problem.

                    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