这种新闻列表要怎么做

禁用F3 2012-05-23 06:32:12
像百度找搜资料一样,上面标题,下面一部份内容,
我用TABL用一列两行,可是只能添加一条新闻,怎么循环呢?
...全文
156 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
VisualTeam 2012-06-10
  • 打赏
  • 举报
回复
先用TABLE做好你排版的方式,再用REPEATER套用
a442545770 2012-05-24
  • 打赏
  • 举报
回复
我觉得还是用listview做吧,repeater做分页不好弄啊, <asp:ListView ID="ListView1" runat="server" >

<ItemTemplate>
<table id="rpt" class="rst_table" border="0" cellpadding="3" style="width: 99%;margin:25px 35px 40px 45px"
cellspacing="1">
<tr>
<td style="width:300px;">
<a href="Shop.aspx?ShopID=<%# Eval("id") %>"><img src="ShopPic.aspx?PID=<%# Eval("picid") %>" alt="" class="imgrst"/><a>
</td>
<td style="width:600px;" >
<a href="Shop.aspx?ShopID=<%# Eval("id") %>">
<table class="ShopInfo">
<tr>
<td>
<span><%# Eval("name")%></span>
</td>
</tr>
<tr>
<td>
<span><%# Eval("shopadd")%></span>
</td>
</tr>
<tr>
<td>
<span><%# Eval("info")%></span>
</td>
</tr>
</table>
<a>
</td>
</tr>
</table>
</ItemTemplate>

</asp:ListView>


i_com = New OracleCommand(str, i_con)
Dim l_ada As OracleDataAdapter = New OracleDataAdapter(i_com)
Dim l_dt As New DataTable
i_con.Open()
i_com.ExecuteNonQuery()
l_ada.Fill(l_dt)
i_con.Close()
Dim a As Integer = l_dt.rows.count
ListView1.DataSource = l_dt
ListView1.DataBind()

yyl8781697 2012-05-24
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 的回复:]

楼上正解,一般把这个截字段写成一个公共方法,方便调用!
[/Quote]
++

/// 截取字符串并限制字符串长度,多于给定的长度+。。。
///
/// 待截取的字符串
/// 每行的长度,多于这个长度自动换行
/// 输出字符串最大的长度
///
public string CutStr(string str,int len,int max)
{
string s="";
string sheng="";
if (str.Length >max)
{
str=str.Substring(0,max) ;
sheng="";
}
for(int i=0;i 53 {
int r= i% len;
int last =(str.Length/len)*len;
if (i!=0 && i<=last)
{

if( r==0)
{
s+=str.Substring(i-len,len)+"
";
}

}
else if (i>last)
{
s+=str.Substring(i-1) ;
break;
}

}

return s+sheng;

}
小孩快跑 2012-05-23
  • 打赏
  • 举报
回复
楼上正解,一般把这个截字段写成一个公共方法,方便调用!
孟子E章 2012-05-23
  • 打赏
  • 举报
回复
<%#Eval("内容字段名").ToString().Substring(0,10) + "..."%>
禁用F3 2012-05-23
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]
<asp:Repeater ID="RepeaterArticlelist" runat="server">
<ItemTemplate>
<table border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td height="30" class="title01" align="left">
<%#Eval("标……
[/Quote]
我要显示一部份的内容,不是全部显示出来。要怎么办呢?
孟子E章 2012-05-23
  • 打赏
  • 举报
回复

<asp:Repeater ID="RepeaterArticlelist" runat="server">
<ItemTemplate>
<table border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td height="30" class="title01" align="left">
<%#Eval("标题字段名")%></td>
</tr>
<tr>
<td height="88" class="text">
<%#Eval("内容字段名")%><br />
</td>
</tr>
<tr>
<td height="20" class="title02">
<a href="target="_blank">>> 阅读全文...</a>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
禁用F3 2012-05-23
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

用repeater
[/Quote]

<asp:Repeater ID="RepeaterArticlelist" runat="server">
<ItemTemplate>
<table border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td height="30" class="title01" align="left">
<%=标题%> </td>
</tr>
<tr>
<td height="88" class="text">
<%=内容%><br />
</td>
</tr>
<tr>
<td height="20" class="title02">
<a href="target="_blank">>> 阅读全文...</a>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>

可这样写不对...
  • 打赏
  • 举报
回复
用repeater

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧