I have a datalist which contain product catagory with unique ID asign to every products in my catalog. However, when i checked 2 or more checkboxes, i will only get the latest data display next page, but not all the data displayed. Just 1 data displayed only. Is there any way i can do so that I can pass 3 different ID at a time and display on nxt page?
void GetCheckedBox()
{
foreach (DataListItem li in DataList1.Items)
{
//access the check checklist
HtmlInputCheckBox cb = li.FindControl("FavChkBox") as HtmlInputCheckBox;
if (cb != null && cb.Checked)
{
ArrayList Product = new ArrayList();
LblText.Text += " , ";
LblText.Text += cb.Value;
Product.Add(cb.Value);
string url = "CompareProducts.aspx?prodId=" + cb.Value.ToString();
Response.Redirect(url);
}
}
}
CompareProducts.aspx.cs
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();
GridView1.DataSource = ds;
GridView1.DataBind();
DataList1.DataSource = ds;
DataList1.DataBind();
}
Aucun commentaire:
Enregistrer un commentaire