示例#1
0
    private void binddata()
    {
        DataTable dt = ServiceNewService.GetNewsViewByType(((UserInfo)Session["ServiceUser"]).U_SID, 9);

        GridView1.DataSource   = dt;
        GridView1.DataKeyNames = new string[] { "N_ID" };//主键
        GridView1.DataBind();
    }
示例#2
0
    void binddata(int sid, int tid)
    {
        DataTable dt = ServiceNewService.GetNewsViewByType(sid, tid);

        AspNetPager1.RecordCount = dt.Rows.Count;
        if (dt.Rows.Count >= 0)
        {
            PagedDataSource ps = new PagedDataSource();
            DataView        dv = new DataView(dt);
            ps.DataSource        = dv;
            ps.AllowPaging       = true;
            ps.CurrentPageIndex  = AspNetPager1.CurrentPageIndex - 1;
            ps.PageSize          = AspNetPager1.PageSize;
            GridView1.DataSource = ps;
            GridView1.DataBind();
        }
    }