Devendra  Kumar

Devendra Kumar

  • NA
  • 517
  • 246.3k

dropdown list select category remove check box checked value

Oct 26 2015 8:41 AM
hi plz solve my problem...
 
select product category in dropdown list then visible related product in datalist..
and then checkbox checked and select product quantity how much..
and when select product another category and  then checkbox checked and select product quantity how much..
button click submit data in to database then insert only last select category  product.
first select product category checked and select product quantity not insert..
 
code.. category change..
protected void ddlist_cat_SelectedIndexChanged(object sender, EventArgs e)
{
objAdmin.Category_Id = int.Parse(ddlist_cat.SelectedValue);
if (ddlist_cat.SelectedValue == "0")
{
DataSet ds1 = objAdmin.Sp_SelectForBulk("AllProduct");
datalistAll.DataSource = ds1;
datalistAll.DataBind();
divleft.Visible = true;
leftside.Visible = false;
sortdiv.Visible = true;
lbl_cat_nm.Text = "All Products";
sbmt_btn.Visible = false;
}
else
{
objAdmin.whole_cat_id = 0;
objAdmin.category_id = int.Parse(ddlist_cat.SelectedValue);
objAdmin.client_fkid = int.Parse(Session["Wholesale_Id"].ToString());
objAdmin.abc = "check";
DataSet ds3 = objAdmin.SelectWholeCategory();
if (ds3.Tables[0].Rows.Count > 0)
{
Session["wholeCatID"] = ds3.Tables[0].Rows[0]["whole_cat_id"].ToString();
objAdmin.whole_cat_id = int.Parse(Session["wholeCatID"].ToString());
objAdmin.category_id = int.Parse(ddlist_cat.SelectedValue);
objAdmin.client_fkid = int.Parse(Session["Wholesale_Id"].ToString());
DataSet ds2 = objAdmin.UpdateWholeCategory();
objAdmin.BindProductDatalist(divProducts);
divleft.Visible = false;
leftside.Visible = true;
sortdiv.Visible = false;
sbmt_btn.Visible = true;
lbl_cat_nm.Text = ddlist_cat.SelectedItem.Text;
}
else
{
objAdmin.whole_cat_id = 0;
objAdmin.category_id = int.Parse(ddlist_cat.SelectedValue);
objAdmin.client_fkid = int.Parse(Session["Wholesale_Id"].ToString());
DataSet ds2 = objAdmin.InsertWholeCategory();
objAdmin.BindProductDatalist(divProducts);
divleft.Visible = false;
leftside.Visible = true;
sortdiv.Visible = false;
sbmt_btn.Visible = true;
lbl_cat_nm.Text = ddlist_cat.SelectedItem.Text;
}
foreach (DataListItem item in divProducts.Items)
{
DropDownList drop_quantity = item.FindControl("drop_quantity") as DropDownList;
for (int i = 1; i <= 100; i++)
{
drop_quantity.Items.Add(i.ToString());
}
}
Session["cat_id"] = int.Parse(ddlist_cat.SelectedValue);
}
}
 
 
 
 
 
 
button click...code
 
 
 
 
protected void sbmt_btn_Click1(object sender, ImageClickEventArgs e)
{
if (Session["whole_categoryfkid"] != null && Session["whole_categoryfkid"] != "")
{
Session["whole_category_fkid"] = Session["whole_categoryfkid"].ToString();
}
else
{
objAdmin.whole_cat_id = 0;
objAdmin.category_id = int.Parse(ddlist_cat.SelectedValue);
objAdmin.client_fkid = int.Parse(Session["Wholesale_Id"].ToString());
objAdmin.abc = "check";
DataSet ds2 = objAdmin.SelectWholeCategory();
if (ds2.Tables[0].Rows.Count > 0)
{
Session["whole_category_fkid"] = ds2.Tables[0].Rows[0]["whole_cat_id"].ToString();
}
}
foreach (DataListItem item in divProducts.Items)
{
Label lbl_pro_nm = item.FindControl("lbl_pro_nm") as Label;
Label lbl_product_id = item.FindControl("lbl_product_id") as Label;
h_productId.Value = lbl_product_id.Text;
CheckBox cb = item.FindControl("chkbox") as CheckBox;
if (cb != null)
{
if (cb.Checked)
{
if (lbl_pro_nm.Text.Length > 0)
{
objAdmin.wholesale_cartId = 0;
objAdmin.wholesale_clientFkId = int.Parse(h_wholesaleId.Value.ToString());
objAdmin.cat_f_kid = 0;
objAdmin.product_ka_naam = lbl_pro_nm.Text;
objAdmin.product_ki_fk_id = 0;
objAdmin.whole_category_fkid = 0;
objAdmin.tpo = "for_checking";
DataSet ds1 = objAdmin.selectWholesaleCartItem();
if (ds1.Tables[0].Rows.Count > 0)
{
Session["Wholesale_cart_id"] = ds1.Tables[0].Rows[0]["wholesale_cartId"].ToString();
objAdmin.wholesale_cartId = int.Parse(Session["Wholesale_cart_id"].ToString());
objAdmin.wholesale_clientFkId = int.Parse(h_wholesaleId.Value.ToString());
objAdmin.cat_f_kid = int.Parse(Session["cat_id"].ToString());
objAdmin.product_ka_naam = lbl_pro_nm.Text;
objAdmin.product_ki_fk_id = int.Parse(h_productId.Value.ToString());
objAdmin.whole_category_fkid = int.Parse(Session["whole_category_fkid"].ToString());
DataSet ds2 = objAdmin.UpdateWholesaleCartItem();
}
else
{
objAdmin.wholesale_cartId = 0;
objAdmin.wholesale_clientFkId = int.Parse(h_wholesaleId.Value.ToString());
objAdmin.cat_f_kid = int.Parse(Session["cat_id"].ToString());
objAdmin.product_ka_naam = lbl_pro_nm.Text;
objAdmin.product_ki_fk_id = int.Parse(h_productId.Value.ToString());
objAdmin.whole_category_fkid = int.Parse(Session["whole_category_fkid"].ToString());
DataSet ds = objAdmin.InsertWholesaleCartItem();
}
}
}
}
}
Response.Redirect("WholesaleOrder.aspx");
}
 
 
 
 
 
checkbox checked code....
 
 
 
 
protected void chkbox_CheckedChanged(object sender, EventArgs e)
{
if (Session["whole_categoryfkid"] != null && Session["whole_categoryfkid"] != "")
{
Session["whole_category_fkid"] = Session["whole_categoryfkid"].ToString();
}
else
{
objAdmin.whole_cat_id = 0;
objAdmin.category_id = int.Parse(ddlist_cat.SelectedValue);
objAdmin.client_fkid = int.Parse(Session["Wholesale_Id"].ToString());
objAdmin.abc = "check";
DataSet ds2 = objAdmin.SelectWholeCategory();
if (ds2.Tables[0].Rows.Count > 0)
{
Session["whole_category_fkid"] = ds2.Tables[0].Rows[0]["whole_cat_id"].ToString();
}
}
foreach (DataListItem item in divProducts.Items)
{
Label lbl_pro_nm = item.FindControl("lbl_pro_nm") as Label;
Label lbl_product_id = item.FindControl("lbl_product_id") as Label;
DropDownList drop_quantity = item.FindControl("drop_quantity") as DropDownList;
h_productId.Value = lbl_product_id.Text;
CheckBox cb = item.FindControl("chkbox") as CheckBox;
if (cb != null)
{
if (cb.Checked)
{
if (lbl_pro_nm.Text.Length > 0)
{
objAdmin.wholesale_cartId = 0;
objAdmin.wholesale_clientFkId = int.Parse(h_wholesaleId.Value.ToString());
objAdmin.cat_f_kid = 0;
objAdmin.product_ka_naam = lbl_pro_nm.Text;
objAdmin.product_ki_fk_id = 0;
objAdmin.whole_category_fkid = 0;
objAdmin.quantity = 0;
objAdmin.tpo = "for_checking";
DataSet ds1 = objAdmin.selectWholesaleCartItem();
if (ds1.Tables[0].Rows.Count > 0)
{
Session["Wholesale_cart_id"] = ds1.Tables[0].Rows[0]["wholesale_cartId"].ToString();
objAdmin.wholesale_cartId = int.Parse(Session["Wholesale_cart_id"].ToString());
objAdmin.wholesale_clientFkId = int.Parse(h_wholesaleId.Value.ToString());
objAdmin.cat_f_kid = int.Parse(Session["cat_id"].ToString());
objAdmin.product_ka_naam = lbl_pro_nm.Text;
objAdmin.quantity = int.Parse(drop_quantity.SelectedValue.ToString());
objAdmin.product_ki_fk_id = int.Parse(h_productId.Value.ToString());
objAdmin.whole_category_fkid = int.Parse(Session["whole_category_fkid"].ToString());
DataSet ds2 = objAdmin.UpdateWholesaleCartItem();
}
else
{
objAdmin.wholesale_cartId = 0;
objAdmin.wholesale_clientFkId = int.Parse(h_wholesaleId.Value.ToString());
objAdmin.cat_f_kid = int.Parse(Session["cat_id"].ToString());
objAdmin.product_ka_naam = lbl_pro_nm.Text;
objAdmin.quantity = int.Parse(drop_quantity.SelectedValue.ToString());
objAdmin.product_ki_fk_id = int.Parse(h_productId.Value.ToString());
objAdmin.whole_category_fkid = int.Parse(Session["whole_category_fkid"].ToString());
DataSet ds = objAdmin.InsertWholesaleCartItem();
}
}
}
}
}
Response.Redirect("WholesaleOrder.aspx");
}
 

Attachment: wholesaleorder.rar