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 Concatenate values from gridview to textbox in asp.net

how to Concatenate values from gridview to textbox in asp.net

Scheduled Pinned Locked Moved ASP.NET
csharpcssasp-nettutorial
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.
  • D Offline
    D Offline
    diyaa_08
    wrote on last edited by
    #1

    how to Concatenate values from gridview to textbox in asp.net i hav a grid n columns are 3 i use that code if (gvProviderCPTFeeNotesEnterNotes.Rows.Count != 0) { string Str = string.Empty; for (int i = 0; i < gvProviderCPTFeeNotesEnterNotes.Rows.Count; i++) { for(int j=0; j< 3; j++) { string Str1 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString(); string Str2 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString(); string Str3 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString(); if (i == 0) { txtProviderCPTFeeNoteViewNotes.Text = string.Format("Date: {0}\r\nContent: {1}\r\nUserID: {2}", Str1, Str2, Str3); Str = txtProviderCPTFeeNoteViewNotes.Text.ToString(); } else { txtProviderCPTFeeNoteViewNotes.Text = string.Format("{0} \r\n\r\n Date: {1}\r\nContent: {2}\r\nUserID: {3}", Str, Str1, Str2, Str3); Str = txtProviderCPTFeeNoteViewNotes.Text.ToString(); } } } }

    N 1 Reply Last reply
    0
    • D diyaa_08

      how to Concatenate values from gridview to textbox in asp.net i hav a grid n columns are 3 i use that code if (gvProviderCPTFeeNotesEnterNotes.Rows.Count != 0) { string Str = string.Empty; for (int i = 0; i < gvProviderCPTFeeNotesEnterNotes.Rows.Count; i++) { for(int j=0; j< 3; j++) { string Str1 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString(); string Str2 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString(); string Str3 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString(); if (i == 0) { txtProviderCPTFeeNoteViewNotes.Text = string.Format("Date: {0}\r\nContent: {1}\r\nUserID: {2}", Str1, Str2, Str3); Str = txtProviderCPTFeeNoteViewNotes.Text.ToString(); } else { txtProviderCPTFeeNoteViewNotes.Text = string.Format("{0} \r\n\r\n Date: {1}\r\nContent: {2}\r\nUserID: {3}", Str, Str1, Str2, Str3); Str = txtProviderCPTFeeNoteViewNotes.Text.ToString(); } } } }

      N Offline
      N Offline
      nagendrathecoder
      wrote on last edited by
      #2

      So, are you getting any error or exception with this code? I didn't understand your question, can you explain a bit.

      diyaa_08 wrote:

      string Str1 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString();

      Also, no need to use ".ToString()" as ".Text" property returns a string only. P.S: Put your code in "pre" tags, it'll enhance the readability.

      -- Modified Wednesday, April 28, 2010 2:03 AM

      D 1 Reply Last reply
      0
      • N nagendrathecoder

        So, are you getting any error or exception with this code? I didn't understand your question, can you explain a bit.

        diyaa_08 wrote:

        string Str1 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString();

        Also, no need to use ".ToString()" as ".Text" property returns a string only. P.S: Put your code in "pre" tags, it'll enhance the readability.

        -- Modified Wednesday, April 28, 2010 2:03 AM

        D Offline
        D Offline
        diyaa_08
        wrote on last edited by
        #3

        <i displayed values in grid view than in ither tabpanel i hav to display these values in a textbox with concatenation string how i do that plz tell me>

        N 1 Reply Last reply
        0
        • D diyaa_08

          <i displayed values in grid view than in ither tabpanel i hav to display these values in a textbox with concatenation string how i do that plz tell me>

          N Offline
          N Offline
          nagendrathecoder
          wrote on last edited by
          #4

          First, tell me whether you want to do this on a particular row selected event or for all rows present in your gridview (Your code is doing this)?

          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