求高手!!!!
datalist控件如何实现显示文章标题加前几行?
最好附上具体代码。,多谢!!!
<asp:DataList ID="DataList1" runat="server">
<ItemTemplate>
<DIV class=Content>
<P align=center><IMG src="images/030307system693.gif">
<A class=WritingTitle href="ArticelDetail.aspx?ID=<%#Eval("ID")%>"><%#Eval("Title") %></A></P>
<P align="center"><%#Eval("WriteTime")%></P>
<P><%#Eval("Content")%></P>
<P>
<IMG src="images/more145.gif"> <A href="ArticelDetail.aspx?ID=<%#Eval("ID")%>">查阅全文</A> <IMG src="images/undo.gif"></P>
<a href="ClassList.aspx?ClassID=<%#Convert.ToString(Eval("ClassID"))%>">类别:<%# GetClassName(Convert.ToString(Eval("ClassID")))%> </a> | 浏览(<%#Eval("Hits")%>) | <a href="ArticelDetail.aspx?ID=<%#Eval("ID")%>#comment">评论(<%# TotalComment(Convert.ToString(Eval("ID")))%>)</a> <%# IsLogin(Convert.ToString(Eval("ID")))%>
<HR style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-LEFT-COLOR: #cccccc; BORDER-TOP-COLOR: #cccccc; BORDER-BOTTOM: #cccccc 1px solid; BORDER-RIGHT-WIDTH: 0px; BORDER-RIGHT-COLOR: #cccccc" SIZE=1 width="700">
</DIV>
</ItemTemplate>
</asp:DataList>
------解决方案--------------------
你的意思是Content字段只显示两行,不显示全部吗?
//把<%#Eval("Content")%>改成下面这个样子,substring的长度自己控件,我随便写了个40
<%# Eval("Content").ToString().Substring(0,40)%>