repeater和DataSet的问题

yanbinquan 2011-03-23 05:51:05
重复的数据用repeater还是用dataset输出比较好呢?哪个效率高


DataSet ds = bll.GetList(top, strWhere, orderby);
if (ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
DataRow dr = ds.Tables[0].Rows[i];
strTxt.Append("<li>");
if (isTime == 1)
{
strTxt.Append("<span>[" + string.Format("{0:MM-dd}", dr["AddTime"]) + "]</span>");
}
strTxt.Append(chrico);
strTxt.Append("<a target=\"_blank\" title=\"" + dr["Title"].ToString() + "\" href=\"News_View.aspx?id=" + dr["Id"] + "\">" + StringPlus.CutString(dr["Title"].ToString(), txtNum) + "</a>");
strTxt.Append("</li>");
}
}
........
...全文
89 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Cool_xiaocao 2011-03-23
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 gongsun 的回复:]

你可以把查询的数据 发送的客户端 在拼接html。

这样数据量会少很多。
[/Quote]

这个主意相对来说比较高效
caicoko 2011-03-23
  • 打赏
  • 举报
回复
你的这种情况建议使用repeater,能使用的就尽量去使用repeater,方便日后修改调整。
RUNBEAR 2011-03-23
  • 打赏
  • 举报
回复
两种不同的东西。啊。
repeater好。
zhouwei7682719 2011-03-23
  • 打赏
  • 举报
回复
不知LZ有多少数据 此人问题更LZ类似
gongsun 2011-03-23
  • 打赏
  • 举报
回复
你可以把查询的数据 发送的客户端 在拼接html。

这样数据量会少很多。
唵嘛呢叭咪吽 2011-03-23
  • 打赏
  • 举报
回复
dataset是数据源
HTML效率更高,不包括开发效率
韩雪枫 2011-03-23
  • 打赏
  • 举报
回复
绘制快些,而且利用SEO
Repeater分页显示 简单的说,先从控件工具箱中拖入两个label(currten page当前页,count page总页),四个linkbuttion(首/下页/上页/尾页)。 无非就是+1 -1 的问题, ------------------------ using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class gonggao : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.labPage.Text = "1"; this.contrlRepeater(); } } //获取指字符个数的字符 public string cuts(string aa,int bb) { if (aa.Length <= bb) { return aa; } else { return aa.Substring(0, bb); } } //Repeater分页控制显示方法 public void contrlRepeater() { pb pb1 = new pb(); DataSet ss = new DataSet(); ss = pb1.returnDs("select top 200 [标题],[时间] from news"); PagedDataSource pds = new PagedDataSource(); pds.DataSource = ss.Tables["temptable"].DefaultView; pds.AllowPaging = true; pds.PageSize = 2; pds.CurrentPageIndex = Convert.ToInt32(this.labPage.Text) - 1; Repeater1.DataSource = pds; LabCountPage.Text = pds.PageCount.ToString(); labPage.Text = (pds.CurrentPageIndex + 1).ToString(); this.lbtnpritPage.Enabled = true; this.lbtnFirstPage.Enabled = true; this.lbtnNextPage.Enabled = true; this.lbtnDownPage.Enabled = true; if(pds.CurrentPageIndex<1) { this.lbtnpritPage.Enabled = false; this.lbtnFirstPage.Enabled = false; } if (pds.CurrentPageIndex == pds.PageCount-1) { this.lbtnNextPage.Enabled = false; this.lbtnDownPage.Enabled = false; } Repeater1.DataBind(); } protected void lbtnpritPage_Click(object sender, EventArgs e) { this.labPage.Text = Convert.ToString(Convert.ToInt32(labPage.Text) - 1); this.contrlRepeater(); } protected void lbtnFirstPage_Click(object sender, EventArgs e) { this.labPage.Text = "1"; this.contrlRepeater(); } protected void lbtnDownPage_Click(object sender, EventArgs e) { this.labPage.Text =this.LabCountPage.Text; this.contrlRepeater(); } protected void lbtnNextPage_Click(object sender, EventArgs e) { this.labPage.Text = Convert.ToString(Convert.ToInt32(labPage.Text) + 1); this.contrlRepeater(); } } -----------------

62,046

社区成员

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

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

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

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