Click here to Skip to main content
15,910,787 members

Comments by Avinash Pratap Singh Rajawat (Top 1 by date)

Avinash Pratap Singh Rajawat 6-May-16 7:59am View    
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
fillcountry();
}




public void fillcountry()
{
foreach (RepeaterItem item in repItemDet.Items)
{
try
{
if (Session["Cart"] == null)
{
CreateCart();
}
DataTable dtMain = (DataTable)Session["Cart"];
DataTable dt = dtMain;
int row = dt.Rows.Count;
dt.Rows.Add();
Label LblPrice = (Label)item.FindControl("LblPrice") as Label;
string txtqty = ((DropDownList)item.FindControl("ddlqty")).SelectedValue;
float Qty = float.Parse(txtqty);
float Price = float.Parse(LblPrice.Text);
double Total = Qty * Price;
Label LblItemId = (Label)item.FindControl("LblItemId") as Label;
Label lblName = (Label)item.FindControl("lblName") as Label;
dt.Rows[row]["Id"] = LblItemId.Text;
dt.Rows[row]["ItemName"] = lblName.Text;
dt.Rows[row]["Qty"] = Qty.ToString();
dt.Rows[row]["Price"] = Price.ToString();
dt.Rows[row]["Total"] = Total.ToString();
dt.AcceptChanges();
Session["Cart"] = dt;
Session["CartItems"] = dt.Rows.Count;

}
catch (Exception ex)
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertmessage", "alert('something wrong with add to cart plz try again')", true);
}
BindMenus();

}


}