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. line break with detailsview control

line break with detailsview control

Scheduled Pinned Locked Moved ASP.NET
databasehelp
9 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.
  • O Offline
    O Offline
    orsini
    wrote on last edited by
    #1

    Hi, I have a field in my sql database that is populated with a lot of parragraph and line breaks, but when I use DetailsView to display the field I get only a big parragraph, any help orsini

    F 1 Reply Last reply
    0
    • O orsini

      Hi, I have a field in my sql database that is populated with a lot of parragraph and line breaks, but when I use DetailsView to display the field I get only a big parragraph, any help orsini

      F Offline
      F Offline
      Fred_Smith
      wrote on last edited by
      #2

      use string.replace function to replace all line breaks with
      tags

      O 1 Reply Last reply
      0
      • F Fred_Smith

        use string.replace function to replace all line breaks with
        tags

        O Offline
        O Offline
        orsini
        wrote on last edited by
        #3

        thanks you so much could you give me an example. i mean not the whole code, but how will be the line.

        F 1 Reply Last reply
        0
        • O orsini

          thanks you so much could you give me an example. i mean not the whole code, but how will be the line.

          F Offline
          F Offline
          Fred_Smith
          wrote on last edited by
          #4

          if s = your string returned fromt he database, you'd use s.replace(vbCrLf, "
          ") in VB - you'll have to look up the C++ or C# versions yourself if you need them... but the VB constant vbCrLf is just the carriage-return line-feed characters which are Chr(13) and Chr(10), so you can maybe work this out yourself... ie, the VB equivalkent is s.replace(Chr(13) & Chr(10), "
          ") (it's probably the same in C except for the ; at the end)

          O 1 Reply Last reply
          0
          • F Fred_Smith

            if s = your string returned fromt he database, you'd use s.replace(vbCrLf, "
            ") in VB - you'll have to look up the C++ or C# versions yourself if you need them... but the VB constant vbCrLf is just the carriage-return line-feed characters which are Chr(13) and Chr(10), so you can maybe work this out yourself... ie, the VB equivalkent is s.replace(Chr(13) & Chr(10), "
            ") (it's probably the same in C except for the ; at the end)

            O Offline
            O Offline
            orsini
            wrote on last edited by
            #5

            thanks, i will try that,

            O 1 Reply Last reply
            0
            • O orsini

              thanks, i will try that,

              O Offline
              O Offline
              orsini
              wrote on last edited by
              #6

              Sorry before i come here i try to make this works , but i can't here is my code, went to the documentation and didnt no find anything, could you help me with that? Dim s As String = SqlDataSource1.SelectCommand("pdescription") s.replace(Chr(13) & Chr(10), "")

              F 1 Reply Last reply
              0
              • O orsini

                Sorry before i come here i try to make this works , but i can't here is my code, went to the documentation and didnt no find anything, could you help me with that? Dim s As String = SqlDataSource1.SelectCommand("pdescription") s.replace(Chr(13) & Chr(10), "")

                F Offline
                F Offline
                Fred_Smith
                wrote on last edited by
                #7

                well, no.. you either need to do this (sort of thing) in the ItemDatabound event, or else in the ItemTemplate of your datalist control instead of just binding it directly to the pdesciption field you have to call a function to format the display, passing the data as argument <%# myFormatFunction( DataBinder.Eval(Container.DataItem, "pdescription") ) %> Then in your code behind the function would be Function myFormatFunction (ByVal s As String) As String Return s.replace(vbCrLf, "
                ") End Function

                O 1 Reply Last reply
                0
                • F Fred_Smith

                  well, no.. you either need to do this (sort of thing) in the ItemDatabound event, or else in the ItemTemplate of your datalist control instead of just binding it directly to the pdesciption field you have to call a function to format the display, passing the data as argument <%# myFormatFunction( DataBinder.Eval(Container.DataItem, "pdescription") ) %> Then in your code behind the function would be Function myFormatFunction (ByVal s As String) As String Return s.replace(vbCrLf, "
                  ") End Function

                  O Offline
                  O Offline
                  orsini
                  wrote on last edited by
                  #8

                  Thank you so much, finally I made it work, i rated your answer as 5, you are the man, lol

                  F 1 Reply Last reply
                  0
                  • O orsini

                    Thank you so much, finally I made it work, i rated your answer as 5, you are the man, lol

                    F Offline
                    F Offline
                    Fred_Smith
                    wrote on last edited by
                    #9

                    well done! - and thanks...

                    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