我用一串数组格式组成的字符串,作为参数传递给页面a.aspx,在这个页面中,将它转化成数组arrselected[].用里面的数据项作为数据绑定的记录的ID号,依次绑定.但是在我对其中的某条记录做删除操作后,想重新帮定,发生了错误 代码如下:
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
pageSize = 5;
        if(!Page.IsPostBack)
{
currentPage = 0; // 初始化当前页为第0页
ViewState["CurrentPage"] = 0;                selectedstring=Request.QueryString["ID"];
//selectedstringTemp=selectedstring;
arrselected = selectedstring.Split(',');
                ViewState["arrselected"]=arrselected;}
public void BindData()
{
int startPage;
startPage = currentPage * pageSize;


//查询语句
string selectStr="select reason,id,hr_depart.dptname,hr_overtimetemp.id,hr_emply.emplyname,hr_overtimekind.overtimename,bgndatetime ,enddatetime ,hr_check.checkname,hr_overtimetemp.checked,sendtime,result  from hr_overtimekind,hr_overtimetemp,hr_depart,hr_check,hr_emply where  hr_check.checked=hr_overtimetemp.checked and hr_depart.dptid=hr_overtimetemp.dptid and hr_overtimekind.overtimekind=hr_overtimetemp.overtimekindid and hr_emply.emplyid=hr_overtimetemp.emplyid and id in (";
//循环获得数组里的数据
for(int i=0;i<arrselected.Length;i++)
{
if(arrselected[i].Trim()!="")
{
selectStr+="'"+arrselected[i]+"',";
}
}
            //去掉最后一个逗号
selectStr = selectStr.Substring(0,selectStr.Length-1);
     selectStr+=") ";
DataSet ds = new DataSet();
hr.conn.Open();
SqlDataAdapter da = new SqlDataAdapter(selectStr,hr.conn);
da.Fill(ds,startPage,pageSize,"Message");
message.DataSource = ds;
message.DataMember = "Message";
message.DataBind();
hr.conn.Close();
}

public void DelOrAlt_Click(object sender,CommandEventArgs e)
{
string commandText; bool result=true;
if(e.CommandName=="Del")
{  

try
{
commandText = "Delete from hr_overtimetemp where id = " + e.CommandArgument;
hr.conn.Open();
SqlCommand comm = new SqlCommand(commandText,hr.conn);
comm.ExecuteNonQuery();
hr.conn.Close();
Response.Write("<script>alert(\"删除成功!\");</script>");
                      int Del=int.Parse(e.CommandArgument.ToString());

arrselected=ViewState["arrselected"].ToString;
for(int i=0;i<arrselected.Length;i++)
{
if(arrselected[i].Trim()!="")
{
if(Del==int.Parse(arrselected[i].ToString()))
{
break; }
}
j++;//记录被删除的数据在数组里的位置
}
//删除数组里的那个被已经被删除的记录对应的值
for(int i=j;i<arrselected.Length-1;i++)
{
arrselected[i]=arrselected[i+1];
}
BindData();
}
catch(SqlException)
{
Response.Write("<script>alert(\"删除失败!\");</script>");
                    result=false;
}        }}发生的错误是::for(int i=j;i<arrselected.Length-1;i++)
{
arrselected[i]=arrselected[i+1];
}
上句里说arrselected未将对象实例化  
请各位大虾帮忙啊