先把2003的代码贴一下。
//父控件
namespace Com991205
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Collections;
/// <summary>
/// Summary description for DiscusModule.
/// </summary>
public class DiscusModule : Com991205.UserModuleControl
{
private const int PAGECOUNT = 10;
public int nTabID = 0;
private ArrayList aAreaID = new ArrayList();
public static int[] AreaID = new int[PAGECOUNT];
private static int nTotalPageCount = 0;
private int nRecordCount = 0;
private int nCurrentPageIndex = 0;
private void Page_Load(object sender, System.EventArgs e)
{
myDataGrid.PageSize = PAGECOUNT;
if(Request.Params["tabId"] != null)
{
nTabID = Int32.Parse(Request.Params["tabId"]);
}
if(ViewState["CurrentPageIndex"] != null)
{
nCurrentPageIndex = Int32.Parse(ViewState["CurrentPageIndex"].ToString());
}
if(Session["Index"] != null)
{
Session["Index"] = null;
}
if(Session["IsBindData"] != null)
{
Session["IsBindData"] = null;
}
if(!Page.IsPostBack)
{
//绑定列表
BindData();
//当前的页码
PageCurrentCount.Text = (nCurrentPageIndex + 1).ToString();
//初始化页面导向按钮的可见性
IsFirstLastPage();
}
}
//子控件
namespace Com991205
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Collections;
/// <summary>
/// Summary description for DisTitleControl.
/// </summary>
public class DisTitleControl : System.Web.UI.UserControl
{
public int areaId = 0;
private int index = 0;
private void Page_Load(object sender, System.EventArgs e)
{
if(Session["Index"] != null)
{
index = Int32.Parse(Session["Index"].ToString());
}
if(Session["IsBindData"] != null)
{
if(Session["IsBindData"].ToString() == "binding")
{
if(index < DiscusModule.AreaID.Length)
{
//在VS2005里会提示找不到DiscusModule类。VS2003可以。
areaId = GetAreaID(DiscusModule.AreaID,index);
}
BindTitleData();
}
}
}
}