2013年5月14日 星期二

資料換行問題

參考資料

在儲存資料的時候會使用換行,一般來說我總是希望我在哪裡換行的
存完之後展示的資料要跟我輸進去的一樣

在讀取的時候用這樣
A.Text = DBValue.Replace("\n", "<br />");
或是
A.Text = DBValue.Replace("\r\n", "<br />");

在GridView裡面的時候這樣表示
e.Row.Cells[2].Text = e.Row.Cells[2].Text.Replace("\n", "<br />");


儲存的時候相反
DBValue= A.Text.Replace( "<br />","\n");
DBValue= A.Text.Replace( "<br />","\r\n");

2 則留言: