控件的只读属性如何设置
一个分页控件的只读属性CurrentPageIndex
public int CurrentPageIndex
{
get
{
return (int)ViewState["CurrentPageIndex"];
}
}
如何咋控件内部给CurrentPageIndex赋值
我函数private void getPageIndex(int RecordCount, int PageCount)当中
private void getPageIndex(int RecordCount, int PageCount)
{
int pageIndex;
// 从Url参数获得当前页码
string queryIndex = HttpContext.Current.Request.QueryString["page"];
if (RecordCount == 0)
pageIndex= 1; // 如果记录数为0,则显示为第一页
省略部分代码。。。。。。。
ViewState["CurrentPageIndex"] = pageIndex;
}
在前台读取控件的CurrentPageIndex的属性时报错
说 return (int)ViewState["CurrentPageIndex"];
未将对象引用设置到对象的实例。