DSC微信投票翻页

时间:2015-04-13 22:32:52   收藏:0   阅读:248

//数据绑定
    public void dlBind(string chatid)
    {
        int curpage = Convert.ToInt32(this.labPage.Text);
        PagedDataSource ps=new PagedDataSource();
        string sql="select id,s.agentname,case when v.votenum is null then 0 when votenum is not null then sum(votenum) end as votenum,case when s.photourl IS NULL then ‘User/UserHeadImage/123.gif‘ else s.photourl end as photourl from staff s left join wxvote v on s.agentname=v.tlname where s.rank in(‘tl‘,‘sup‘) and s.quit is null and s.unit in (select unit from staff where wechatid=‘"+ chatid +"‘) group by id,s.agentname,v.votenum,s.photourl order by id";
        SqlDataAdapter da=new SqlDataAdapter(sql,SqlHelper.mycon);
        DataSet ds=SqlHelper.ExecuteDataset(SqlHelper.mycon,CommandType.Text, sql);
        da.Fill(ds,"vote_table");
        ps.DataSource=ds.Tables["vote_table"].DefaultView;
        ps.AllowPaging=true;
        ps.PageSize=9;
        ps.CurrentPageIndex=curpage-1;
        lnkbtnFst.Enabled = true;
        lnkbtnLast.Enabled = true;
        lnkbtnUp.Enabled = true;
        lnkbtnNext.Enabled = true;
        if(curpage==1)
        {
            this.lnkbtnFst.Enabled=false;
            this.lnkbtnUp.Enabled=false;
        }
        if(curpage==ps.PageCount)
        {
            this.lnkbtnNext.Enabled=false;
            this.lnkbtnLast.Enabled=false;
        }
        this.labLstPage.Text=Convert.ToString(ps.PageCount);
        this.dlContent.DataSource=ps;
        this.dlContent.DataKeyField="id";
        this.dlContent.DataBind();
    }

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!