当前位置:编程学习 > C#/ASP.NET >>

DataList 中如何实现自动换行

<asp:DataList ID="test" runat="server" width="220">
          <ItemTemplate>
            <table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td height="15"> <%# Eval("cTitle") %></td>
              </tr>
              <tr>
                <td background="images/line5.gif"><img alt="" src="images/line5.gif" width="3" height="1" /></td>
              </tr>
            </table>
          </ItemTemplate>
          <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" ForeColor="Blue"  HorizontalAlign="Center" />        
        </asp:DataList>


在为表格的宽度有限,而里面的标题内容又想完全显示,DataList 或是 GridView有没有属性可以设置成表格显示满了实现自动换行的.
请大伙指教. --------------------编程问答-------------------- page_load事件中写

test.Attributes.Add("style", "word-break:break-all;word-wrap:break-word");
--------------------编程问答-------------------- 同意楼上 --------------------编程问答--------------------
<asp:DataList ID="test" runat="server" width="220">
          <ItemTemplate>
            <table width="97%" border="0" align="center" cellpadding="0" cellspacing="0" style="word-break:break-all;word-wrap:break-word">
              <tr>
                <td height="15"> <%# Eval("cTitle") %></td>
              </tr>
              <tr>
                <td background="images/line5.gif"><img alt="" src="images/line5.gif" width="3" height="1" /></td>
              </tr>
            </table>
          </ItemTemplate>
          <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" ForeColor="Blue"  HorizontalAlign="Center" />        
        </asp:DataList>
--------------------编程问答-------------------- 晕..刚发的效果没出来,直接用css,注意红色部分
<asp:DataList ID="test" runat="server" width="220">
          <ItemTemplate>
            <table width="97%" border="0" align="center" cellpadding="0" cellspacing="0" style="word-break:break-all;word-wrap:break-word">
              <tr>
                <td height="15"> <%# Eval("cTitle") %></td>
              </tr>
              <tr>
                <td background="images/line5.gif"><img alt="" src="images/line5.gif" width="3" height="1" /></td>
              </tr>
            </table>
          </ItemTemplate>
          <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" ForeColor="Blue"  HorizontalAlign="Center" />        
        </asp:DataList>
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,