日期:2014-05-19  浏览次数:20500 次

高手们分不多了,帮一个简单的Datakeys问题 在线等 分不多,完了就结
protected   void   BindToBBS_(int   pageIndex,string   TitleCou)
        {
                int   n   =   pageIndex   *   int.Parse(TitleCou);
                int   m   =   (pageIndex   -   1)   *   int.Parse(TitleCou);
                string   sql   =   "select   top   "   +   TitleCou   +   "   BBS_ID,BBS_title   as   title,BBS_addtime   as   times,Auid=(select   UserID   from   [user]   where   UserName=BBS.BBS_author), ";
                sql   +=   "reply=(select   count(*)   from   Reply   where   Reply.bbs_ID   =BBS.BBS_ID),Ruid=(select   UserID   from   [User]   where   UserName=(select   top   1   reply_author ";
                sql+= "   from   reply   where   reply.BBS_ID   =   BBS.BBS_ID   order   by   reply_addtime   desc)), ";
                                sql+= "BBS_author   as   author,zonename=(select   zone_name   from   zone   where   zone_ID=BBS.Zone_ID), ";
                                sql+= "BBS_Click   as   click,BBS_tags   as   tags,last=(select   top   1   reply_author   from   reply   where   reply.BBS_ID   =   BBS.BBS_ID   ";
                                sql+= "order   by   reply_addtime   desc),lasttime=(select   top   1   reply_addtime   from   reply   where   reply.BBS_ID   =   BBS.BBS_ID   ";
                                sql+= "order   by   reply_addtime   desc),zoneID=(select   zone_ID   from   zone   where   Zone.zone_ID=BBS.Zone_ID),BBS_Click   as   click   from   ";
                                sql+= "bbs   where   BBS_ID   in   (select   top   "+n+ "   BBS_ID   from   BBS   order   by   BBS_ID   desc)   and   BBS_ID   ";
                                sql   +=   "not   in   (select   top   "+m+ "   BBS_ID   from   BBS   order   by   BBS_ID   desc)   order   by   BBS_ID   desc ";                        
                                this.DataList1.DataSource   =   cn.DataSets(sql);
                                this.DataList1.DataK