line break with detailsview control
-
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
use string.replace function to replace all line breaks with
tags -
use string.replace function to replace all line breaks with
tags -
thanks you so much could you give me an example. i mean not the whole code, but how will be the line.
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) -
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) -
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), "")
-
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), "")
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 -
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 -
well done! - and thanks...