【!急!】如何让RadioListBox在翻页的时候不会初始化???
hhcsb 2008-07-16 05:41:29 RadioListBox相当于是一个筛选器,比如可以查看“未通过名单”“通过名单”“所有名单”,然后单击一个选项就可用查看相应的一些数据,RadioListBox已经AutoPostBack了。
数据绑定用的是Repeater来显示的。翻页的用的是Lable超链接,当我单击翻页链接的时候,本来地址是xxx.aspx?topage=2&npage=通过名单,表示我要查看第二页的通过名单的数据,可是一点击翻页后,RadioListBox就初始化到“所有名单”了,显示数据也变成了第二页的所有数据的东西了xxx.aspx?topage=2&npage=所有名单……
现在求高手帮我解决这个问题,如何翻页后还是显示的当前的RadioListBox的所有数据???困扰我两天了……
DataSet ds = new DataSet();
string npage = q("npage");
string switchRB1 = RB1.SelectedValue;
int PageSize = 2;
int PageCount, RecordCount;
int ToPage = Convert.ToInt32(Request.QueryString["ToPage"]);
string pagesql = null, sql = null;
switch (switchRB1)
{
case "未通过审核":
sql = "select count(id) from Company_Basemeans where isPast='未通过'";
break;
case "通过审核":
sql = "select count(id) from Company_Basemeans where isPast='通过'";
break;
case "企业总数":
sql = "select count(id) from Company_Basemeans";
break;
case "申请图招":
sql = "select count(id) from Company_Basemeans where piczp = '申请通过图招'";
break;
}
string sqlstr = ConfigurationManager.ConnectionStrings["0745Job"].ToString();
SqlConnection conn = new SqlConnection(sqlstr);
SqlCommand MyComm = new SqlCommand(sql, conn);
conn.Open();
RecordCount = Convert.ToInt32(MyComm.ExecuteScalar());
conn.Close();
if (RecordCount % PageSize != 0)
{
PageCount = RecordCount / PageSize + 1;
}
else
{
PageCount = RecordCount / PageSize;
}
if (ToPage == Convert.ToInt32(null))
{
ToPage = 1;
}
if (ToPage > PageCount)
{
ToPage = PageCount;
}
if (ToPage <= 1)
{
switch (switchRB1)
{
case "未通过审核":
pagesql = "select....";
break;
case "通过审核":
pagesql = "select....";
break;
case "企业总数":
pagesql = "select....";
break;
case "申请图招":
pagesql = "select....";
break;
}
}
else
{
switch (switchRB1)
{
case "未通过审核":
pagesql = "select....";
break;
case "通过审核":
pagesql = "select....";
break;
case "企业总数":
pagesql = "select....";
break;
case "申请图招":
pagesql = "select...."
break;
}
}
if (ToPage <= 1)
{
LinkPrev.Enabled = false;
Linkhead.Enabled = false;
CurrentPage.Text = "1";
}
else
{
LinkPrev.Enabled = true;
LinkPrev.NavigateUrl = "?ToPage=" + (ToPage - 1) + "&npage=" + switchRB1;
Linkhead.Enabled = true;
Linkhead.NavigateUrl = "?ToPage=1&npage=" + switchRB1;
}
if (ToPage >= PageCount)
{
LinkFoot.Enabled = false;
LinkNext.Enabled = false;
CurrentPage.Text = PageCount.ToString();
}
else
{
LinkFoot.Enabled = true;
LinkFoot.NavigateUrl = "?ToPage=" + PageCount + "&npage=" + switchRB1;
LinkNext.Enabled = true;
LinkNext.NavigateUrl = "?ToPage=" + (ToPage + 1) + "&npage=" + switchRB1;
}
//**********************Label控件绑定**********************
TotalPage.Text = Convert.ToString(PageCount);
CurrentPage.Text = Convert.ToString(ToPage);
LbRecord.Text = RecordCount.ToString();
LbPageRecord.Text = PageSize.ToString();
//**********************数据绑定**********************
SqlDataAdapter da = new SqlDataAdapter(pagesql, conn);
da.Fill(ds, "ShowPage");
RP1.DataSource = ds.Tables["ShowPage"].DefaultView;
RP1.DataBind();