asp.netC#未将对象引用设置到对象的实例。显示购物车,用的datalist控件,但是显示不出来,应该怎样改
protectedvoidPage_Load(objectsender,EventArgse){if(!IsPostBack){DataList1.DataSource=...
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataList1.DataSource = (Hashtable)Session["bus"];
DataList1.DataBind();//需要加载模板才能显示
SqlConnection con = db.CreateCon();
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
string userid = Session["userid"].ToString();
string petid = Session["petid"].ToString();
cmd.CommandText = "select * from bus ";
SqlDataReader sdr = cmd.ExecuteReader();
cmd.ExecuteNonQuery();
Response.Write("宠物编号" + petid + "数量" + num + "用户名" + userid);
}
} 展开
{
if (!IsPostBack)
{
DataList1.DataSource = (Hashtable)Session["bus"];
DataList1.DataBind();//需要加载模板才能显示
SqlConnection con = db.CreateCon();
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
string userid = Session["userid"].ToString();
string petid = Session["petid"].ToString();
cmd.CommandText = "select * from bus ";
SqlDataReader sdr = cmd.ExecuteReader();
cmd.ExecuteNonQuery();
Response.Write("宠物编号" + petid + "数量" + num + "用户名" + userid);
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询