标题:怎么显示才不重复?
只看楼主
cctvkmn
Rank: 1
等 级:新手上路
帖 子:98
专家分:0
注 册:2008-11-22
结帖率:63.16%
 问题点数:0 回复次数:1 
怎么显示才不重复?
<div style="border:1px solid #CDCDCD; width:500px;float:left; margin-left:15px; margin-top:33px;">
  <div style=" border-bottom:1px solid #CDCDCD; height:30px; width:510px;">
  <div style=" font-size:14px; font-weight:bold; padding-top:9px; padding-left:9px; padding-bottom:5px; float:left;">热门推荐</div>
  <div style="float:right; padding-top:9px; padding-bottom:3px; margin-right:3px;font-size:12px;"> <a href="#">更多</a> </div>
  </div>
  <div style="float:left;">
   <asp:Repeater ID="tt" runat="server" OnItemDataBound="tt_ItemDataBound">
    <ItemTemplate>
  <div style="width:470px; float:left;padding-top:12px;">
  <div style="float:left; padding-top:12px; padding-left:20px;">
  <div style="border:1px solid #CDCDCD;font-size:0px; padding:2px; width:78px; height:100px;"> 图片 </div>
  </div>
  <div style=" float:right;">
  <div style="font-size:12px;">
  <ul >
  <asp:Repeater ID="yy" runat="server">
                   <ItemTemplate>
  <li style="padding-bottom:5px;">《<%#Eval("dtNames")%>》</li>
  </ItemTemplate>
                   </asp:Repeater>
  </ul>
  </div>
  </div>
  <div style=" float:left; padding-top:16px; padding-left:10px; font-size:12px;">
  <div>名字:<%#Eval("dtNames")%>
  </div>
  </div>
  <div style="border-top:1px dotted #ccc; margin-top:140px; margin-left:20px;"> </div>
  </ItemTemplate>
       </asp:Repeater>

  </div>
  </div>
</div>

数据库大概结构dtWorker:

Id dtNames dtImage dtwzId dtTime

1   名字1   图片1    1    时间1

2   名字2   图片2    1    时间2

3   名字3   图片3    2    时间3

4   名字4   图片4    2    时间4

5   名字5   图片5    2    时间5

6   名字6   图片6    2    时间6

。。。。。。。。。。


左边Repeater(tt)我sql select top 2 * from dtWorker where dtwzId=1


        string sql = "select top 2 * from dtWorker where dtwzId=1";

        SqlConnection sqlcon = new SqlConnection(DBHelper.ConnectionStringLocalTransaction);

        sqlcon.Open();

        SqlDataAdapter adp = new SqlDataAdapter(sql, sqlcon);

        DataSet ds = new DataSet();

        adp.Fill(ds);

        tt.DataSource = ds;
        tt.DataBind();




右边Repeater(yy)我也是这样写:

        string sql = "select top 6 * from dtWorker where dtwzId=2";

        SqlConnection sqlcon = new SqlConnection(DBHelper.ConnectionStringLocalTransaction);

        sqlcon.Open();

        SqlDataAdapter adp = new SqlDataAdapter(sql, sqlcon);

        DataSet ds = new DataSet();

        adp.Fill(ds);

        yy.DataSource = ds;
        yy.DataBind();

可是为什么右边(yy)得到的数据是重复的?
左边却没有重复却递增了?
同样是循环绑定为什么结果不一样?
求解!谢谢!
搜索更多相关主题的帖子: asp border style right 
2011-10-08 01:25
cctvkmn
Rank: 1
等 级:新手上路
帖 子:98
专家分:0
注 册:2008-11-22
得分:0 
yy是在tt的tt_ItemDataBound事件中绑定的:

 if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {

            
         string sql = "select top 6 * from dtWorker where dtwzId=2";

        SqlConnection sqlcon = new SqlConnection(DBHelper.ConnectionStringLocalTransaction);

        sqlcon.Open();

        SqlDataAdapter adp = new SqlDataAdapter(sql, sqlcon);

        DataSet ds = new DataSet();

        adp.Fill(ds);
        Repeater yyy= (Repeater)e.Item.FindControl("yy");
        yyy.DataSource = ds;
        yyy.DataBind();



        }
2011-10-08 01:29



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-351771-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.212694 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved