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 Join Two Table in Dataset and show in Gridview Joined Both Tables...

How to Join Two Table in Dataset and show in Gridview Joined Both Tables...

Scheduled Pinned Locked Moved C#
questiondatabasecomtutorial
4 Posts 4 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
    Shaik Haneef
    wrote on last edited by
    #1

    I have two table Employee and EmployeeAddress and Both Cotain ID filed with integer, I want to Join both in DataSet How can i do it ??? select * from Employee, EmployeeAddress where Employee.ID= EmployeeAddress.ID I want to do the the above sql operation in my Dataset & need to display in girdview My Dataset Contain two Table one is for Results of Employee another table contains details of EmployeeAddress. How can Provide First Table as Primary and Second Table as Forign Key I tried that Dataset objds=new Dataset(); ...... ...... //Analyse that Dataset contain two tables of data now then How can I provide relation and need to give to Gridview objds.Relations.Add("Relation",objds.Tables[0].Column["ID"],objds.Tables[1].Column["ID"]); Gridview1.Datasource = objds; Gridview1.DataBind(); But it showing only First Table Data only I want to Join both tables as one and need to show in Gridview How can do It ? Regars, Shaik Haneef sk.haneef@gmail.com

    D M L 3 Replies Last reply
    0
    • S Shaik Haneef

      I have two table Employee and EmployeeAddress and Both Cotain ID filed with integer, I want to Join both in DataSet How can i do it ??? select * from Employee, EmployeeAddress where Employee.ID= EmployeeAddress.ID I want to do the the above sql operation in my Dataset & need to display in girdview My Dataset Contain two Table one is for Results of Employee another table contains details of EmployeeAddress. How can Provide First Table as Primary and Second Table as Forign Key I tried that Dataset objds=new Dataset(); ...... ...... //Analyse that Dataset contain two tables of data now then How can I provide relation and need to give to Gridview objds.Relations.Add("Relation",objds.Tables[0].Column["ID"],objds.Tables[1].Column["ID"]); Gridview1.Datasource = objds; Gridview1.DataBind(); But it showing only First Table Data only I want to Join both tables as one and need to show in Gridview How can do It ? Regars, Shaik Haneef sk.haneef@gmail.com

      D Offline
      D Offline
      dojohansen
      wrote on last edited by
      #2

      I don't think the GridView supports this, but you can try adding databound columns at design-time, this might permit you to bind some columns to the first table and some to the second. I doubt it tho.

      1 Reply Last reply
      0
      • S Shaik Haneef

        I have two table Employee and EmployeeAddress and Both Cotain ID filed with integer, I want to Join both in DataSet How can i do it ??? select * from Employee, EmployeeAddress where Employee.ID= EmployeeAddress.ID I want to do the the above sql operation in my Dataset & need to display in girdview My Dataset Contain two Table one is for Results of Employee another table contains details of EmployeeAddress. How can Provide First Table as Primary and Second Table as Forign Key I tried that Dataset objds=new Dataset(); ...... ...... //Analyse that Dataset contain two tables of data now then How can I provide relation and need to give to Gridview objds.Relations.Add("Relation",objds.Tables[0].Column["ID"],objds.Tables[1].Column["ID"]); Gridview1.Datasource = objds; Gridview1.DataBind(); But it showing only First Table Data only I want to Join both tables as one and need to show in Gridview How can do It ? Regars, Shaik Haneef sk.haneef@gmail.com

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        Make sure that ID refers to the correct ID in both tables, on if then will be the ID for address and the other will be the ID for the customer. There should be a CustomerID on the address table! You need to have done some study during your course, surely!

        Never underestimate the power of human stupidity RAH

        1 Reply Last reply
        0
        • S Shaik Haneef

          I have two table Employee and EmployeeAddress and Both Cotain ID filed with integer, I want to Join both in DataSet How can i do it ??? select * from Employee, EmployeeAddress where Employee.ID= EmployeeAddress.ID I want to do the the above sql operation in my Dataset & need to display in girdview My Dataset Contain two Table one is for Results of Employee another table contains details of EmployeeAddress. How can Provide First Table as Primary and Second Table as Forign Key I tried that Dataset objds=new Dataset(); ...... ...... //Analyse that Dataset contain two tables of data now then How can I provide relation and need to give to Gridview objds.Relations.Add("Relation",objds.Tables[0].Column["ID"],objds.Tables[1].Column["ID"]); Gridview1.Datasource = objds; Gridview1.DataBind(); But it showing only First Table Data only I want to Join both tables as one and need to show in Gridview How can do It ? Regars, Shaik Haneef sk.haneef@gmail.com

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Use LINQ to DataSet to query and join the 2 tables. The query result can be bound to the Grid or used to create a new DataTable for binding to.

          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