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. how to display data in a gridview?

how to display data in a gridview?

Scheduled Pinned Locked Moved ASP.NET
helptutorialdatabasequestion
6 Posts 3 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.
  • W Offline
    W Offline
    wajans
    wrote on last edited by
    #1

    Hi I have 2 tables in database as follows: table1: id name state id 1 aaa 1,2 2 bbb 1,3 table2: id state 1 ak 2 ny 3 jk so the problem is that I want to display all the data of "table1" in a gridview and in place of "state id" I want to display "statename", for example in place of "1,2" I want to display "ak,ny". How to do this? Please help me:confused:. Thanks

    D C 2 Replies Last reply
    0
    • W wajans

      Hi I have 2 tables in database as follows: table1: id name state id 1 aaa 1,2 2 bbb 1,3 table2: id state 1 ak 2 ny 3 jk so the problem is that I want to display all the data of "table1" in a gridview and in place of "state id" I want to display "statename", for example in place of "1,2" I want to display "ak,ny". How to do this? Please help me:confused:. Thanks

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

      Are you asking for help with building an SQL statement? If so, it might look like this: Select t1.*, t2.State as StateAcro from table1 as t1 inner join table2 as t2 on (t1.id=t2.id) Otherwise, could you elaborate a bit more?

      My Personal Site

      W 1 Reply Last reply
      0
      • D doWhileSomething

        Are you asking for help with building an SQL statement? If so, it might look like this: Select t1.*, t2.State as StateAcro from table1 as t1 inner join table2 as t2 on (t1.id=t2.id) Otherwise, could you elaborate a bit more?

        My Personal Site

        W Offline
        W Offline
        wajans
        wrote on last edited by
        #3

        Hi Thanks for replying. ids in table1 are seperated with commas so t1.id=t2.id will not work. I need asp.net code to display table1 values as I explained in my previous post. Thanks

        1 Reply Last reply
        0
        • W wajans

          Hi I have 2 tables in database as follows: table1: id name state id 1 aaa 1,2 2 bbb 1,3 table2: id state 1 ak 2 ny 3 jk so the problem is that I want to display all the data of "table1" in a gridview and in place of "state id" I want to display "statename", for example in place of "1,2" I want to display "ak,ny". How to do this? Please help me:confused:. Thanks

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Seems to me like you need to design your db better in future ( a joining table would have made this doable in the SQL ). You can read your array of state names and Ids, then write a data binding statement that passes the id string to the code behind, where you use the split method and a string builder to build a string that contains the state abbreviations.

          Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          W 1 Reply Last reply
          0
          • C Christian Graus

            Seems to me like you need to design your db better in future ( a joining table would have made this doable in the SQL ). You can read your array of state names and Ids, then write a data binding statement that passes the id string to the code behind, where you use the split method and a string builder to build a string that contains the state abbreviations.

            Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

            W Offline
            W Offline
            wajans
            wrote on last edited by
            #5

            Hi Christian Thanks for reply Actually I am displaying names of states in a checkbox list and after submitting the form, storing selected checkbox stateids in database with stateids seperated by comma as in table1. If you have any working example or else any suggestion, please send it. Thanks

            C 1 Reply Last reply
            0
            • W wajans

              Hi Christian Thanks for reply Actually I am displaying names of states in a checkbox list and after submitting the form, storing selected checkbox stateids in database with stateids seperated by comma as in table1. If you have any working example or else any suggestion, please send it. Thanks

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              What I said. A joining table joins data where there's an arbitrary number of joins id name state id 1 aaa 1,2 2 bbb 1,3 table2: id state 1 ak 2 ny 3 jk table3: nameId, stateId 1, 1 1, 2 2, 1 2, 3 then table 1 loses the stateID column.

              Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

              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