lordofphp
جمعه 10 آذر 1391, 22:44 عصر
به نام خدا
سلام دوستان من دارم یه سبد خرید به aspx مینویسم به سی شارپ
تقریبا تموم شده اما این قسمتش با مشکل بر میخورم
if (Session["cart"] == null)
Label1.Text = "سبدخرید شما تهیست لطفا با مراجعه به صفحه اصلی فروشگاه نسبت به خرید اقدام نمائید";
Class1 class1 = new Class1();
ArrayList cart = new ArrayList();
if (Session["cart"] != null)
{
cart = (ArrayList)Session["cart"];
foreach (Class1 ins in cart)
{
ListBox1.Items.Add(ins.name);
}
اما وقتی سبدخرید پر میشه صفحه کارت که سبد خرید نشون میده خالیه
محتویات کلاس هم همین:
public class Class1
{
public string name;
//
// TODO: Add constructor logic here
//
}
اما با لود صفحه ی کارت که محتویاتش بالا گذاشتم اررور:
Server Error in '/WebSite1' Application.
Unable to cast object of type 'System.String' to type 'Class1'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'System.String' to type 'Class1'.
سلام دوستان من دارم یه سبد خرید به aspx مینویسم به سی شارپ
تقریبا تموم شده اما این قسمتش با مشکل بر میخورم
if (Session["cart"] == null)
Label1.Text = "سبدخرید شما تهیست لطفا با مراجعه به صفحه اصلی فروشگاه نسبت به خرید اقدام نمائید";
Class1 class1 = new Class1();
ArrayList cart = new ArrayList();
if (Session["cart"] != null)
{
cart = (ArrayList)Session["cart"];
foreach (Class1 ins in cart)
{
ListBox1.Items.Add(ins.name);
}
اما وقتی سبدخرید پر میشه صفحه کارت که سبد خرید نشون میده خالیه
محتویات کلاس هم همین:
public class Class1
{
public string name;
//
// TODO: Add constructor logic here
//
}
اما با لود صفحه ی کارت که محتویاتش بالا گذاشتم اررور:
Server Error in '/WebSite1' Application.
Unable to cast object of type 'System.String' to type 'Class1'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'System.String' to type 'Class1'.