none
listview 显示时 替换 字段中的内容 (C#) RRS feed

  • 问题

  • <asp:ListView ID="ListView2" runat="server" DataKeyNames="id"
                        DataSourceID="SqlDataSource2" ondatabound="ListView2_DataBound">
                        <ItemTemplate>
                          <span style=" font-size:10.5pt; line-height:1.6em;color:#595959; font-family: arial,宋体,">

    <asp:Label ID="ContentLabel" runat="server" Text='<%# Bind("Content")%>' />
                               </span>
                              <br />
                              <div style="height:5px;"></div>
                              <span style="font-size:9pt; line-height:2em; color:#92cbc4;">
                              <asp:Label ID="addtime" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "addTime","{0:yyyy年MM月dd日 HH:mm:ss}") %>' />
                                       <a href="View.aspx?id=<%#Eval("ID") %>">评论</a>
                             </span>

                             <center>
                             <div style="background-color:#DDDDDD;height:1px; margin-top:5px; margin-bottom:10px;">
                             </div>
                             </center>
                        </ItemTemplate>

                        <EmptyDataTemplate>
                          <span></span>
                        </EmptyDataTemplate>

                        <LayoutTemplate>
                          <div ID="itemPlaceholderContainer" runat="server" style="">
                            <span ID="itemPlaceholder" runat="server" />
                          </div>
                          <div style="">
                            <asp:DataPager ID="DataPager1" runat="server" PageSize="10">
                              <Fields>
                                <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True"
                                  ShowLastPageButton="True" />
                              </Fields>
                            </asp:DataPager>
                          </div>
                        </LayoutTemplate>


                      </asp:ListView>

    --------------------------------------

    我想替换Content字段中的部分内容,在显示的时候就同时把把Chr(13)替换为<br/> ,请问应该怎么办?

           <%# Replace(Bind("Content"),chr(13),"<br/>")%>     出错。奇怪啊。
    2012年2月24日 6:07

答案

全部回复