private void binddata() { DataTable dt = ServiceNewService.GetNewsViewByType(((UserInfo)Session["ServiceUser"]).U_SID, 9); GridView1.DataSource = dt; GridView1.DataKeyNames = new string[] { "N_ID" };//主键 GridView1.DataBind(); }
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(); } }