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. Formatting text in datagrid.

Formatting text in datagrid.

Scheduled Pinned Locked Moved ASP.NET
helpquestion
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.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    Hello, I want to display a large amount of data in my datagrid column, but the problem is when i fetch data, it just appends all lines and fetches as a single paragraph, but i want to preserve the paragraph, spaces or blank lines and fetch exactly the way i have typed in my textbox. Any idea?

    S A 2 Replies Last reply
    0
    • A Anonymous

      Hello, I want to display a large amount of data in my datagrid column, but the problem is when i fetch data, it just appends all lines and fetches as a single paragraph, but i want to preserve the paragraph, spaces or blank lines and fetch exactly the way i have typed in my textbox. Any idea?

      S Offline
      S Offline
      sivilian
      wrote on last edited by
      #2

      The reason it does this is that the datagrid renders as an HTML table, and tables do not see whitespace as textboxes, or textareas do, in that they merge whitespace and do not understand line breaks. One way to overcome this is to replace all spaces with   and all line breaks with
      or

      . hope this helps, sivilian

      1 Reply Last reply
      0
      • A Anonymous

        Hello, I want to display a large amount of data in my datagrid column, but the problem is when i fetch data, it just appends all lines and fetches as a single paragraph, but i want to preserve the paragraph, spaces or blank lines and fetch exactly the way i have typed in my textbox. Any idea?

        A Offline
        A Offline
        Albert Pascual
        wrote on last edited by
        #3

        Create a Template and when you get the string sYourString.Replace("\r", "
        ); Is that what you were asking? Al

        M 1 Reply Last reply
        0
        • A Albert Pascual

          Create a Template and when you get the string sYourString.Replace("\r", "
          ); Is that what you were asking? Al

          M Offline
          M Offline
          MeterMan
          wrote on last edited by
          #4

          DataGrids to my understanding do not recognize whitepage so yeah do like he is saying. what i do is this. i have a templated column and its id is TextBox1. Also in the html part where you see the template put in TextMode=MultiLine; that way you can have a scroll and type in whatever you want. It doesn't understand the whitespace and breaks so to make it understand it do like Albert Mentioned. TextBox tb1 = ((TextBox)e.Item.FindControl("TextBox1")); tb1.Text= tb1.Text.Replace("\n","
          "); what this will do is take the current text of your textbox and where it fines new lines you want to add a
          so it does a break. I hope this helps. Win32newb "Programming is like sex, make one mistake and you have to support it for a long time"

          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