public void GetPage()
{
string content1 = "";
string Select = "|";
content1 = content;
getString(content1);
if (content.IndexOf("|") > -1)
{
content = array[0].ToString();
}
else
{
LinkButton1.Visible = false;
LinkButton2.Visible = false;
}
}
public void getString(string content)
{
if (content.Length > 0)
{
int count = content.IndexOf("|");
if (count > -1)
{
int length = content.Length;
string newContent = content.Substring(0, count);
array.Add(newContent);
content = content.Substring(count + 1);
getString(content);
}
else
{
array.Add(content);
}
}
Session["array"] = array;
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
array = (ArrayList)Session["array"];
if (array.Count > 0)
{
upPage = Convert.ToInt16(ViewState["Page"]);
if (upPage > 0)
{
upPage--;
if (upPage <= array.Count && upPage > 0)
{
content = array[upPage].ToString();
}
else
{
content = array[0].ToString();
}
ViewState["Page"] = upPage;
LinkButton2.Text = "下一页";
if (upPage == 0)
{
LinkButton1.Text = "首页";
}
}
else
{
LinkButton1.Text = "首页";
content = array[0].ToString();
ViewState["Page"] = 0;
}
}
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
array = (ArrayList)Session["array"];
if (array.Count > 0)
{
upPage = Convert.ToInt16(ViewState["Page"]);
if (upPage < array.Count - 1)
{
upPage++;
if (upPage <= array.Count && upPage > 0)
{
content = array[upPage].ToString();
}
else
{
content = array[0].ToString();
}
ViewState["Page"] = upPage;
LinkButton1.Text = "上一页";
if (upPage == array.Count - 1)
{
LinkButton2.Text = "尾页";
}
}
else
{
LinkButton2.Text = "尾页";
content = array[array.Count - 1].ToString();
ViewState["Page"] = array.Count - 1;
}
}
}