帮我调试以下
protected void btnprevPage_Click(object sender, EventArgs e)
{
Panel pnlPanel;
string strPanelName;
strPanelName = "pnlForm " + ViewState[ "CurrentPage "];
pnlPanel = FindControl(strPanelName);
pnlPanel.Visible = false;
ViewState[ "CurrentPage "] -= "1 ";
strPanelName = "pnlForm " + ViewState[ "CurrentPage "];
pnlPanel = FindControl(strPanelName);
pnlPanel.Visible = true;
}
------解决方案--------------------补充,再更正一下:
protected void btnprevPage_Click(object sender, EventArgs e)
{
Panel pnlPanel;
string strPanelName;
strPanelName = "pnlForm " + ViewState[ "CurrentPage "].ToString();
// FindControl返回的类型要强制转换
pnlPanel = (Panel)FindControl(strPanelName);
pnlPanel.Visible = false;
// 需要数值型才能运算
(int)ViewState[ "CurrentPage "] -= 1;
strPanelName = "pnlForm " + ViewState[ "CurrentPage "].ToString();
pnlPanel = (Panel)FindControl(strPanelName);
pnlPanel.Visible = true;
}