-
Notifications
You must be signed in to change notification settings - Fork 0
/
Default.aspx.cs
67 lines (56 loc) · 1.9 KB
/
Default.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
dsNewsTableAdapters.NewsCategoryTableAdapter taNewsCategory = new dsNewsTableAdapters.NewsCategoryTableAdapter();
dsNews.NewsCategoryDataTable dtNewsCategory;
dsNewsTableAdapters.NewsTableAdapter taNews = new dsNewsTableAdapters.NewsTableAdapter();
dsNews.NewsDataTable dtNews;
public int CurrentPage
{
get
{
// look for current page in ViewState
object o = this.ViewState["_CurrentPage"];
if (o == null)
return 0; // default to showing the first page
else
return (int)o;
}
set
{
this.ViewState["_CurrentPage"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
dtNewsCategory = taNewsCategory.SelectNewsCategoryNameByNewsCategoryId(5);
if (dtNewsCategory.Rows.Count > 0)
{
int page = 10;
dtNews = taNews.SelectNewsbyNewsCategoryId(5);
if (dtNews.Rows.Count > 0)
{
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = dtNews.DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = page;
objPds.CurrentPageIndex = CurrentPage;
Repeater1.DataSource = objPds;
Repeater1.DataBind();
}
else
{
Repeater1.Visible = false;
}
}
else
{
Repeater1.Visible = false;
}
}
}