Currently, I have no idea how to pass multiple selected checkbox to the CompareProduct.aspx. I only can pass 1 selected checkbox to next page at a time .
This is Products.aspx :
<asp:DataList ID="DataList1" runat="server" RepeatColumns="3" RepeatDirection="Horizontal" BorderColor="Black" GridLines="Horizontal" BorderStyle="Solid">
<ItemTemplate>
<input runat="server" id="FavChkBox" type="checkbox" value='<%#Eval("Product_ID") %>' />
COMPARE <a href='ProductItems.aspx?prodId=<%#Eval("Product_ID")%>'><img src="Images/<%#Eval("Product_Image") %>" height="330" width="300" /> </a>
Name:
<asp:Label ID="prodNameLabel" runat="server" Text='<%# Eval("Product_Name") %>' />
<br />
Price:
<asp:Label ID="prodPriceLabel" runat="server" Text='<%# Eval("Unit_Price") %>' />
<br />
</td>
I am using datalist to display the selected items i have select from Products.cs
Below are CompareProducts.aspx.cs codes:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Product aProd = new Product();
SqlConnection con = new SqlConnection(strcon);
SqlCommand cmd = new SqlCommand("SELECT * FROM Products WHERE Product_ID = @ProdID", con);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
cmd.Parameters.AddWithValue("@ProdID", Page.Request.QueryString["ProdID"].ToString());
con.Open();
adp.Fill(ds, "Products");
cmd.ExecuteNonQuery();
con.Close();
DataList1.DataSource = ds;
DataList1.DataBind();
}
Any help will be greatly appreciated! :)
Aucun commentaire:
Enregistrer un commentaire