Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello Everybody,I am working on the simple shopping website and now I am working on the cart_page and I trying to make cart_page by using the asp.net profile.Even I already write the code to enter the one product in the profile.But if the user want to enter the number of products.Then the problem will be occur.So can you please tell me how to use the System.Collections.Generic.List in the asp.net profile.Here below is the code to enter the one product in using profile:

Web.config:-

<pre lang="xml"> <authentication mode="Windows" />
    <anonymousIdentification enabled="true"/>
    <profile automaticSaveEnabled="false" >
      </providers>-->
      <properties>
        <add name="Id" type="int" allowAnonymous="true"/>
        <add name="Name" type="String" allowAnonymous="true" />
        <add name="ImageUrl" type="String" allowAnonymous="true"/>
        <add name="Price" type="int" allowAnonymous="true"/>
        <add name="Item" type="int" allowAnonymous="true" />
        </properties>
    </profile>


This is the coding of Cart_page.
ProfileShopcart.aspx.cs:-

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
((Label)DataList1.Controls[0].FindControl("LblName")).Text = (Profile.Name).ToString();
((Image)DataList1.Controls[0].FindControl("Image1")).ImageUrl = (Profile.ImageUrl).ToString();
(((TextBox)DataList1.Controls[0].FindControl("TxtItem")).Text) = (Profile.Item).ToString();
(((Label)DataList1.Controls[0].FindControl("LblPrice")).Text) = (Profile.Price).ToString();
Profile.Save();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Profile.Name = ((Label)DataList1.Controls[0].FindControl("LblName")).Text;
Profile.ImageUrl = ((Image)DataList1.Controls[0].FindControl("Image1")).ImageUrl;
Profile.Item = int.Parse(((TextBox)DataList1.Controls[0].FindControl("TxtItem")).Text);
Profile.Price = int.Parse(((Label)DataList1.Controls[0].FindControl("LblPrice")).Text);
string ProductID = (Request.QueryString["ProductID"]);


Profile.Save();
}

}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900