我實際上是試圖在一個asp.net項目中使用c#的一個字符串中放置一個換行符。我把這個字符串放到一個DataRow中,並添加到一個名爲「ds」的數據集中。一旦我把這個datable ds鏈接到了gridview。 這是我的代碼:DataTable和GridView中的換行符
risque.projet = dt.Rows[i]["fk_projet"].ToString();
risque.release = dt.Rows[i]["fk_release"].ToString();
//Create the String for adding to the row
String test = "Project:"+risque.projet+"<br>"+ "Release: "+risque.release;
drow["Description"] = test;
Label1.Text = test;
//Add the row to the datatable.
ds.Rows.Add(drow);
//Link the datatable to the gridview
GridView1.DataSource = ds;
GridView1.DataBind();
我想這樣的輸出:
項目:.......
發佈:.......
,但我總是有:項目:....發佈......
我嘗試了許多解決方案: -System.Environment.NewLine - \ r \ n - \ n
編輯:代碼我gridView.I沒有什麼在我的網格視圖,因爲所有是在運行時創建的。
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
EnableSortingAndPagingCallbacks="True" PageSize="5">
<SelectedRowStyle Wrap="True" />
</asp:GridView>
但沒有什麼效果。 br標籤的作品,但只有當我在標籤中顯示我的字符串。
您對我的錯誤有了解嗎?您有解決方案嗎?我在這上面花了太多時間。
謝謝
昆汀
你可以顯示Gridview的aspx代碼嗎? – David