private
string
GetContents()
{
this
._TotalPage
=
((
this
.TotalRecord
/
this
.Info.PageSize)
*
this
.Info.PageSize
==
this
.TotalRecord)
?
(
this
.TotalRecord
/
this
.Info.PageSize) : ((
this
.TotalRecord
/
this
.Info.PageSize)
+
1
);
int
BeginRecord
=
(
this
.PageIndex
-
1
)
*
this
.Info.PageSize
+
1
;
int
EndRecord
=
Math.Min(
this
.PageIndex
*
this
.Info.PageSize,
this
.TotalRecord);
string
PageInfo
=
string
.Format(
"
[每页<span style='color:#CC0000'>{0}({1}-{2})</span>条 共<span style='color:#CC0000'>{3}</span>条<span style='color:#CC0000'>{4}</span>页]
"
, Info.PageSize, BeginRecord, EndRecord,
this
.TotalRecord,
this
.TotalPage);
StringBuilder PageListStr
=
new
StringBuilder();
string
PageIndexColor
=
"
#000000
"
;
int
SingleNumber
=
this
.TotalPage
-
(TotalPage
/
BarSize)
*
BarSize;
int
IntPageForMax
=
(
this
.PageIndex
-
1
)
/
BarSize;
int
MinInt
=
(
1
+
BarSize
*
IntPageForMax);
int
MaxInt
=
((IntPageForMax
+
1
)
*
BarSize)
>
TotalPage
?
TotalPage : ((IntPageForMax
+
1
)
*
BarSize);
if
(
this
.TotalRecord
==
0
||
this
.TotalPage
==
0
)
{
PageListStr.AppendFormat(
"
<span style='color:'{0};margin:auto 3px;'>0</span>
"
, PageIndexColor);
PageListStr.AppendFormat(
"
[共<span style='color:#CC0000'>0</span>页/当前第<span style='color:#CC0000'>0</span>页 共<span style='color:#CC0000'>0</span>条记录,当前记录数<span style='color:#CC0000'>0</span>到<span style='color:#CC0000'>0</span>]
"
);
return
PageListStr.ToString();
}
else
{
if
(
this
.TotalPage
<=
this
.BarSize)
{
for
(
int
i
=
1
; i
<=
TotalPage; i
++
)
{
PageIndexColor
=
PageIndex
==
i
?
"
#CC0000
"
:
"
#000000
"
;
if
(PageIndex
==
i)
PageListStr.AppendFormat(
"
<a id='{0}' style='color:{1};margin:auto 3px;'>{2}</a>
"
,
this
.UniqueID, PageIndexColor, i);
else
PageListStr.AppendFormat(
"
<a id='{0}' style='color:{1};margin:auto 3px;' href=\
"
javascript:{
2
}\
"
>{3}</a>
"
,
this
.UniqueID, PageIndexColor, Page.ClientScript.GetCallbackEventReference(
this
, i.ToString(),
"
AjaxPagerCallBack
"
,
null
), i);
}
PageListStr.AppendFormat(
"
{0}
"
, PageInfo);
return
PageListStr.ToString();
}
else
{
for
(
int
i
=
MinInt; i
<=
MaxInt; i
++
)
{
PageIndexColor
=
PageIndex
==
i
?
"
#CC0000
"
:
"
#000000
"
;
if
(PageIndex
==
i)
PageListStr.AppendFormat(
"
<a id={0}' style='color:{1};margin:auto 3px;'>{2}</a>
"
,
this
.UniqueID, PageIndexColor, i);
else
PageListStr.AppendFormat(
"
<a id='{0}' style='color:{1};margin:auto 3px;' href=\
"
javascript:{
2
}\
"
>{3}</a>
"
,
this
.UniqueID, PageIndexColor, Page.ClientScript.GetCallbackEventReference(
this
, i.ToString(),
"
AjaxPagerCallBack
"
,
null
), i);
}
if
(PageIndex
<=
BarSize
&&
TotalPage
>
BarSize)
{
PageListStr.AppendFormat(
"
<a id='{0}' href=\
"
javascript:{
1
}\
"
>下一页</a>
"
,
this
.UniqueID, Page.ClientScript.GetCallbackEventReference(
this
, System.Convert.ToString(BarSize
+
1
),
"
AjaxPagerCallBack
"
,
null
));
}
if
(
this
.PageIndex
>
BarSize
&&
(TotalPage
-
this
.PageIndex)
>=
SingleNumber)
{
int
MultiMinPageIndex
=
(IntPageForMax
*
BarSize);
int
MultiMaxPageIndex
=
((IntPageForMax
+
1
)
*
BarSize)
+
1
;
PageListStr.Insert(
0
,
string
.Format(
"
<a id='{0}' href=\
"
javascript:{
1
}\
"
>上一页</a>
"
,
this
.UniqueID, Page.ClientScript.GetCallbackEventReference(
this
, MultiMinPageIndex.ToString(),
"
AjaxPagerCallBack
"
,
null
)));
PageListStr.AppendFormat(
"
<a id='{0}' href=\
"
javascript:{
1
}\
"
>下一页</a>
"
,
this
.UniqueID, Page.ClientScript.GetCallbackEventReference(
this
, MultiMaxPageIndex.ToString(),
"
AjaxPagerCallBack
"
,
null
));
}
if
(PageIndex
>
10
&&
(TotalPage
-
PageIndex)
<
SingleNumber)
{
int
MultiMinPageIndex
=
(IntPageForMax
*
BarSize);
PageListStr.Insert(
0
,
string
.Format(
"
<a id='{0}' href=\
"
javascript:{
1
}\
"
>上一页</a>
"
,
this
.UniqueID, Page.ClientScript.GetCallbackEventReference(
this
, MultiMinPageIndex.ToString(),
"
AjaxPagerCallBack
"
,
null
)));
}
PageListStr.AppendFormat(
"
{0}
"
, PageInfo);
return
PageListStr.ToString();
}
}
}
public
void
BindData()
{
Repeater rpt
=
getRpt();
rpt.Visible
=
true
;
SqlHelper helper;
helper
=
this
.Info.ConnectStringName.IsNullOrEmpty()
?
new
SqlHelper() :
new
SqlHelper(Info.ConnectStringName);
if
(
this
.Info.RepeaterUniqueID.IsNullOrEmpty())
{
throw
new
Exception(
"
必须给Info的RepeaterUniqueID属性赋值
"
);
}
int
count
=
0
;
DataTable dt
=
helper.GetPageData(Info.TableName, Info.Fields, Info.IdentityField, Info.PageSize, PageIndex, Info.IsDesc, Info.Content,
out
count);
this
.TotalRecord
=
count;
rpt.DataShow(dt);
}
private
Repeater getRpt()
{
return
this
.Page.FindControl(
this
.Info.RepeaterUniqueID)
as
Repeater;
}