this is my 2nd post in this forum. I am having a difficulty to find a way that when i click the add button it will link to the car page with the same item info from the part page. please check the code below: This is the layout of the item page:
<%@ Page Title="Parts" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Carshop.Pages.Parts.Default"%>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
Parts
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField HeaderText="PartID" DataField="PartID"></asp:BoundField>
<asp:BoundField HeaderText="ItemName" DataField="ItemName"></asp:BoundField >
<asp:BoundField HeaderText="ItemDesciption" DataField="ItemDesciption"></asp:BoundField >
<asp:BoundField HeaderText="Company" DataField="Company"></asp:BoundField >
<asp:BoundField HeaderText="Price" DataField="Price" DataFormatString="{0:c}" ></asp:BoundField >
<asp:ImageField HeaderText="Images" DataImageUrlField="Images"></asp:ImageField>
<asp:BoundField HeaderText="Active" DataField="Active"></asp:BoundField >
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Button1" runat="server" Text="Add" PostBackUrl="~/Pages/Cart/Default.aspx"></asp:Button>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
-------------------------------------------------------------
this is the code behide of the page:
namespace Carshop.Pages.Parts
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
using (DBEntities entities = new DBEntities())
{
GridView1.DataSource = entities.tblParts.ToList();
GridView1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
// what method should I code here?
}
}
}
--------------------------------------------------------------
shopping cart codes:
namespace Carshop.Entities
{
//Sealed to stop unwelcome dependencies
public sealed class Shoppingcart
{
//singleton is a adesgin pattern
//Only one object can be created
private static Shoppingcart instance;
//Private Data Members
private int PartID { get; set; }
private string ItemName { get; set; }
private string ItemDesciptiopn { get; set; }
private Shoppingcart() { }
public static Shoppingcart SetShoppingcart (string _ItemName, string _ItemDesciption)
{
if (instance == null)
{
instance = new Shoppingcart();
instance.ItemName = _ItemName;
instance.ItemDesciptiopn = _ItemDesciption;
}
return instance;
}
}
}
-----------------------------------------------
cart page:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Carshop.Pages.Cart.Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
Cart
<asp:GridView ID="GridView1" runat="server"></asp:GridView>
</asp:Content>