Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Actually this is more improved question of previously asked to show that what is actual problem (guyz its not a duplicate question of my previous one , just improved to explain the problem ),,,,,therefor that its not working as want.....

the problem is -->

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,

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 ??????

.aspx

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 ????????

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();

                String subtotal = Request.QueryString["subtotal"];
                String granttotal = Request.QueryString["granttotal"];

                span_subtotal.InnerText = subtotal;
                span_subtotal.InnerText = granttotal;
            }       
        }

        public int[] bindtotal(int tax, int total)
        {
            int ptax = 0;
            ptax = ptax + tax;

            int subtotal = 0;
            subtotal = subtotal + total;

            int granttotal = 0;
            granttotal = granttotal + subtotal;

            span_subtotal.InnerText = subtotal.ToString();
            span_granttotal.InnerText = granttotal.ToString();

            int[] totals = { subtotal, granttotal };
            return totals;
        }

        public void BindCartListView()
        {
            int tax = 0;
            int total = 0;

            if (Request.QueryString["pid"] != null)
            {
                DataTable producttable = new BALCate().GetProductDeatils(int.Parse(Request.QueryString["pid"].ToString()));
                DataTable carttable = (DataTable)Session["cart_table"];
                DataRow cartrow;
                DataRow productrow;
                if (carttable.Rows.Count <= 0)                         
                {
                    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());                

                    tax = int.Parse(cartrow["Ptax"].ToString());
                    total = int.Parse(cartrow["Total"].ToString());
                }
                else
                { 
                    bool flag = true;
                    foreach (DataRow dr in carttable.Rows)
                    {
                        if (int.Parse(dr["Pid"].ToString()) == int.Parse(producttable.Rows[0]["pid"].ToString()))      
                        {
                            flag = false;
                        }
                    }

                    if (flag)
                    {
                        cartrow = carttable.NewRow();
                        productrow = producttable.Rows[0];
                        cartrow["Pid"] = productrow["pid"];
                        cartrow["PImage"] = productrow["pimg_mid1"];
                        cartrow["Pprice"] = productrow["pcost"];
                        cartrow["Pqty"] = Request.QueryString["qty"];                              
                        cartrow["Pname"] = productrow["pname"];
                        cartrow["Total"] = int.Parse(productrow["pcost"].ToString()) * int.Parse(cartrow["Pqty"].ToString());  

                        carttable.Rows.Add(cartrow);
                    }
                }

                int[] totals;
                totals = bindtotal(tax, total);

                int subtotal = totals[0];
                int granttotal = totals[1];

                ListView_Cart.DataSource = carttable;
                ListView_Cart.DataBind();
                Response.Redirect("ShoppingCart.aspx?subtotal="+subtotal);
            }
            else
            {
                DataTable dt = (DataTable)Session["cart_table"];
                ListView_Cart.DataSource = dt;
                ListView_Cart.DataBind();
            }
        }        
    }
Posted
Updated 20-Oct-12 4:45am
v2
Comments
Parwej Ahamad 20-Oct-12 11:27am    
I believe it should work, please check for span color, is the color same as your background? OR go to view source and see if vale exist.
2nd thing I would ask, why you are not using Label OR Literal instead span?

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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