Click here to Skip to main content
15,881,766 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
actually i have to access the tax & total from the cart table as given below , and then assign them to the span in aspx page by assigning those values to their innertext, so that i worked ,,,,,,,, but it doesnt working-->
.aspx
HTML
subtotal:
<span id="span_subtotal"  runat="server"></span>                         
<br/>Total:<span id="span_granttotal"  runat="server"></span>
.cs
the innertext of these spans r sitll empty to run the below code............can any one help me about this ????????
C#
protected void Page_Load(object sender, EventArgs e)
{
   if (!IsPostBack)
   {
      if (Session["cart_table"] == null)
      {
         DataTable dt = new Spcart().GetCart();
         Session["cart_table"] = dt;                  
      }
      BindCartListView();            
   }
}

public void bindtotal(int tax, int total)
{
   int ptax = 0;
   ptax = ptax + tax;
   int subtotal = 0;
   subtotal = subtotal + total;
   int granttotal = 0;
   granttotal = granttotal + ptax +subtotal;

   ///////////setting innertext///////////////////////
   span_subtotal.InnerText = subtotal.ToString();
   span_granttotal.InnerText = granttotal.ToString();
}

public void BindCartListView()
{
   DataTable producttable = new BALCate().GetProductDeatils(int.Parse(Request.QueryString["pid"].ToString()));
   DataTable carttable = (DataTable)Session["cart_table"];
   DataRow cartrow;
   DataRow productrow;
   cartrow = carttable.NewRow();
   productrow = producttable.Rows[0];
   cartrow["Pid"] = productrow["pid"];
   cartrow["PImage"] = productrow["pimg_mid1"];
   cartrow["Pprice"] = productrow["pcost"];
   cartrow["Pqty"] = int.Parse(Request.QueryString["qty"].ToString());                
   cartrow["Pname"] = productrow["pname"];
   cartrow["ptax"] = productrow["ptax"];
   cartrow["Total"] = int.Parse(productrow["pcost"].ToString()) * int.Parse(cartrow["Pqty"].ToString());  
   carttable.Rows.Add(cartrow);        
   int tax=int.Parse(cartrow["Ptax"].ToString());
   int total = int.Parse(cartrow["Total"].ToString());
   bindtotal(tax, total);        

   ListView_Cart.DataSource = carttable;
   ListView_Cart.DataBind();
   Response.Redirect("ShoppingCart.aspx");
}
Posted
Updated 19-Oct-12 11:19am
v2

1) Suggestion: Using .aspx, rather than placing a span there, why not use the asp:Literal control.
2) When you debug your code, do you have valid values for tax and total when you come to bindtotal(tax, total);? If you hit the breakpoint and you get to that line of code, then you should be ok.
3) When dealing with currency, int is not the way to go. The safest way to work with currency is to use either float, decimal, or double.
 
Share this answer
 
Comments
ashokdamani 19-Oct-12 17:35pm    
yeah,,, i'd used breakpoint & debuged my code BUT the problen is too complicated...--> i'd seen that the innertext(assigned text) correctly showing by pointing mouse there at debugging in bindtotal() method,,, but this text not showing on the .aspx page,,,i mean that span text on aspx page still being empty even assigned. why ??????
Dude, After assigning the innertText for span, you navigating to the ShoppingCart.aspx page. so it seems you are loading the page again. so all your values gets Empty.

Comment the last line of ur code
C#
Response.Redirect("ShoppingCart.aspx");

and see the result. I hope it solves you.
 
Share this answer
 
Comments
ashokdamani 20-Oct-12 9:50am    
@sanjeev : i'hv explain it more in next question ,plz see my next question
i'd fixed it as u said that page redirects & loaded again, so that span becomes empty , i'd fixed it by some more affords , but still doesnt working....
plz see it soon n solve my problem...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900