grideview绑定的objectdatasource
selectmethod 查出来的东西Customer called to check the information about:Sequencing: Difficult Template Hear From: Select Message: test <br/> call taker: Elain Wu Extension:
<asp:TemplateField HeaderText="Action Notes" SortExpression="actionnotes">
<ItemTemplate>
<asp:Label runat="server" ID="lblhehe" Text='<%#Server.HtmlDecode(Eval("actionnotes").ToString()) %>'></asp:Label> </ItemTemplate> </asp:TemplateField>
数据库的表里action这个字段倒是没有<br/>为什么显示出来actionnotes不换行。
selectmethod 查出来的东西Customer called to check the information about:Sequencing: Difficult Template Hear From: Select Message: test <br/> call taker: Elain Wu Extension:
<asp:TemplateField HeaderText="Action Notes" SortExpression="actionnotes">
<ItemTemplate>
<asp:Label runat="server" ID="lblhehe" Text='<%#Server.HtmlDecode(Eval("actionnotes").ToString()) %>'></asp:Label> </ItemTemplate> </asp:TemplateField>
数据库的表里action这个字段倒是没有<br/>为什么显示出来actionnotes不换行。
/n/r 服务器才能识别时换行!
<asp:Label runat="server" ID="lblhehe" Text='<%# Eval("actionnotes") %>'>
</asp:Label>
因为我记得HTML标记是LABEL可以解释的
所以取值的时候昨天高人指点,用select replace(字段,calltaker,<br>calltaker)
今天绑定上了。但是没换行。不知道为什么
是不是字段中用\r\n啊?这样处理<asp:Label runat="server" ID="lblhehe" Text='<%#AnotherLing(Eval("actionnotes").ToString()) %>'></asp:Label>
.cs中protected string AnotherLing(string actionnotes)
{
return actionnotes.Replace("\r\n","<br>");
}
直接输出就行了
读数据时用string.replace("|","<br />")
即:
<asp:Label runat="server" ID="lblhehe" Text='<%# Eval("actionnotes").replace("|","<br />" %>'>
</asp:Label>
Phone Call CRM contact lead Customer called to Elain Wu
check the information about:Sequencing:
test Call Taker: Elain Wu Extension:
这是gridview用objectdatasource绑定的。
就是不知道calltaker这怎么不换行呢?
加个样式,在把lable宽度设置一下试试
<ItemTemplate>
<%#Eval("actionnotes").ToString() %>
</ItemTemplate>别用服务器控件绑定,要么去掉,要么换客户端控件试试