2

I am developing an intranet ASP.NET web site. I am saving user comments from an asp.net multiline textbox into a SQL Server database, and display exactly as it is written by user in Gridview.

Suppose a user enter following string:

1.Task1
2.Task2
3.Task3

then the retreived data in the gridview should be same as user entered it before saving.

While debugging, I tried replacing \r\n with <br/> but gridview is displaying <br/> as it is..not tasking a new line.

I am using c#.

I have found the solution for it Using Literal Control.

Now, there is one new Problem where i am not using Gridview.I am generating Comments as html and sending it as a mail body, Suppose a user enter following string:

1.Task1
   a.T1
   b.T2
   c.T3
2.Modules
  a.Module A
  b.Module B
  c.Module C

Line Break <br /> when Replaced with /n is taking the content only to new line not taking spaces for Second Line Automatically.and the mail body html is generating it like this:

 1.Task1  
 a.T1  
 b.T2  
 c.T3  
 2.Modules  
 a.Module A  
 b.Module B  
 c.Module C  

Which is not what i Expect.

Please Help. Thanks.

nks
  • 61
  • 2
  • 12

1 Answers1

1

You can use carriage returns when you save the text and when displaying it in the grid, you can replace it as

'<%# Eval("TheName").ToString().Replace("\n", "<br />") %>'
Srinivas
  • 1,063
  • 7
  • 15