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. concatenating strings into one datagrid cell

concatenating strings into one datagrid cell

Scheduled Pinned Locked Moved C#
questioncsharpalgorithmstutorial
8 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.
  • F Offline
    F Offline
    falles01
    wrote on last edited by
    #1

    Hello if anyone can please give me just a tiny sample of how I'd do this, not just what to do I will be so grateful. Just so you know. I have been googling for days on this and I'm not sure what to do as I am still pretty new to c#. This is what I want to do. I have a dataset and datagrid(search results table) displaying results like this. Siann Skills1 Siann Skills2 Siann Skills3 I want it to show this Siann Skills1,Skills2,Skills3. I have my select statement, then I have created a new datacolumn as I was told to do as below. Now after that, what do I do? How do I get all the skills in one column. I know I have to concatenate, and I have tried searching the net, but I can't find anything useful. is there any possibility for an example? dgSearchResults.Columns.Add(new DataColumn("skills", GetType())); :)

    C 1 Reply Last reply
    0
    • F falles01

      Hello if anyone can please give me just a tiny sample of how I'd do this, not just what to do I will be so grateful. Just so you know. I have been googling for days on this and I'm not sure what to do as I am still pretty new to c#. This is what I want to do. I have a dataset and datagrid(search results table) displaying results like this. Siann Skills1 Siann Skills2 Siann Skills3 I want it to show this Siann Skills1,Skills2,Skills3. I have my select statement, then I have created a new datacolumn as I was told to do as below. Now after that, what do I do? How do I get all the skills in one column. I know I have to concatenate, and I have tried searching the net, but I can't find anything useful. is there any possibility for an example? dgSearchResults.Columns.Add(new DataColumn("skills", GetType())); :)

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

      You need to change your SQL so that you generate groups of skills for the one name, then you can render it easily from there.

      Christian Graus - Microsoft MVP - C++ "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 )

      F 1 Reply Last reply
      0
      • C Christian Graus

        You need to change your SQL so that you generate groups of skills for the one name, then you can render it easily from there.

        Christian Graus - Microsoft MVP - C++ "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 )

        F Offline
        F Offline
        falles01
        wrote on last edited by
        #3

        Thanks but apparently I can't for some reason. I think I need a for each statement. It is just I don't know exactly what to put in there. I have foreach (DataSet1.EmpSkillsRow empskillsRow in empskillsDT.Rows) { } Apparently then I have to create an empty string and then another text string and then for each loop fill the particular cell. Basically every time a TechnicalSkillID belongs to the same EmployeeID, then display in the TechnicalSkills column in one cell. No one seems to know how this is done in C#. We all know what to do but not how exactly. Do you know? thanks kindly really.

        C 1 Reply Last reply
        0
        • F falles01

          Thanks but apparently I can't for some reason. I think I need a for each statement. It is just I don't know exactly what to put in there. I have foreach (DataSet1.EmpSkillsRow empskillsRow in empskillsDT.Rows) { } Apparently then I have to create an empty string and then another text string and then for each loop fill the particular cell. Basically every time a TechnicalSkillID belongs to the same EmployeeID, then display in the TechnicalSkills column in one cell. No one seems to know how this is done in C#. We all know what to do but not how exactly. Do you know? thanks kindly really.

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

          If you're using SQL Server 2005, I'd say this[^] is what you need.

          Christian Graus - Microsoft MVP - C++ "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 )

          F 2 Replies Last reply
          0
          • C Christian Graus

            If you're using SQL Server 2005, I'd say this[^] is what you need.

            Christian Graus - Microsoft MVP - C++ "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 )

            F Offline
            F Offline
            falles01
            wrote on last edited by
            #5

            Thanks that looks really useful. I'll try it out. (will prob take me a while to convert it into what i need) but I'll let you know how I go. :)

            1 Reply Last reply
            0
            • C Christian Graus

              If you're using SQL Server 2005, I'd say this[^] is what you need.

              Christian Graus - Microsoft MVP - C++ "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 )

              F Offline
              F Offline
              falles01
              wrote on last edited by
              #6

              oh I thought I had 2005 but I was just told that the back end is still 2000. So is there any other option? Sorry. :(

              C 1 Reply Last reply
              0
              • F falles01

                oh I thought I had 2005 but I was just told that the back end is still 2000. So is there any other option? Sorry. :(

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

                I'm not sure, I'd suggest asking in the SQL forum.

                Christian Graus - Microsoft MVP - C++ "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 )

                F 1 Reply Last reply
                0
                • C Christian Graus

                  I'm not sure, I'd suggest asking in the SQL forum.

                  Christian Graus - Microsoft MVP - C++ "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 )

                  F Offline
                  F Offline
                  falles01
                  wrote on last edited by
                  #8

                  I got a response from the sql forum but I worked it out myself. Let me know if you want my answer. I have another simple question but I will post a new message. :)

                  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