
System.InvalidCastException: 无法将类型为“System.String”的对象强制转换为类型“System.Collections.A
protectedvoidbtnPush_Click(objectsender,EventArgse){if(Session["yhName"]==null){Respo...
protected void btnPush_Click(object sender, EventArgs e)
{
if (Session["yhName"] == null)
{
Response.Redirect("bbs.aspx");
}
else
{
ArrayList yhname = (ArrayList)Session["yhname"];
string sql = "insert into rebbs (bcid,yhname,rbcotent) values( '" + Request.Params["id"] + ",'"+yhname+"','" + txtRecontent.Text + "')";
using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["kingclickConnectionString"].ConnectionString))
{
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.ExecuteNonQuery();
conn.Close();
}
DataList2.DataBind();
txtRecontent.Text = "";
}
Response.Write("<script language=javascript>alert('回复成功!')</script>");
}
}
求高手指点 展开
{
if (Session["yhName"] == null)
{
Response.Redirect("bbs.aspx");
}
else
{
ArrayList yhname = (ArrayList)Session["yhname"];
string sql = "insert into rebbs (bcid,yhname,rbcotent) values( '" + Request.Params["id"] + ",'"+yhname+"','" + txtRecontent.Text + "')";
using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["kingclickConnectionString"].ConnectionString))
{
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.ExecuteNonQuery();
conn.Close();
}
DataList2.DataBind();
txtRecontent.Text = "";
}
Response.Write("<script language=javascript>alert('回复成功!')</script>");
}
}
求高手指点 展开
1个回答
展开全部
ArrayList yhname = (ArrayList)Session["yhname"];
你确定你的Session内是一个集合对象吗?如果不是集合对象你这样显式转换是会出错的哦,应该先实例化一个集合对象,然后用.add()方法添加进集合里。
你确定你的Session内是一个集合对象吗?如果不是集合对象你这样显式转换是会出错的哦,应该先实例化一个集合对象,然后用.add()方法添加进集合里。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询