2012-10-19 36 views
2

其實我已經從車臺訪問稅收&總如下面給出的,然後他們的innerText這些值分配給它們分配給aspx頁面的跨度,跨度的innerText並不在同一個頁面分配甚至

我使用斷點& debuged我的代碼,但一點改進是太複雜...-->我看到的innerText(分配的文本)正確地通過在調試中bindtotal有指向鼠標表示()方法,,,但這個文本沒有在.aspx頁面上顯示,,,我的意思是說,aspx頁面上的span文本仍然是空的,甚至分配。爲什麼??????

的.aspx

<b>subtotal:</b> 
<span id="span_subtotal" runat="server"></span>       
<br/> 
<b>Total:</b>       
<span id="span_granttotal" runat="server"></span> 

的.cs

這些跨距的innerTextř羅納爾多,也很想空運行下面的代碼............可以任何一個幫我關於這個????????

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"); 
} 

回答

1

這可能是事實,你在BindCartListView()方法結束做了。

我不知道在什麼頁面,你後面的代碼發佈是的,但你可以保存值Session,或送他們作爲查詢字符串,並在ShoppingCart.aspx代碼設置它的後面。

QUERYSTRING僞代碼:

Response.Redirect("ShoppingCart.aspx?subtotal=" + subtotal + "&granttotal=" + granttotal); 

ShoppingCart.aspx.cs背後的僞代碼代碼:

// Provided you have these span elements in ShoppingCart.aspx. 
span_subtotal.InnerText = Request.QueryString["subtotal"]; 
span_granttotal.InnerText = Request.QueryString["granttotal"]; 
+0

那麼什麼將B液,而不刪除它(的Response.Redirect(「我的購物。 aspx「)),它的必要性bcoz ?????????????? –

+0

@AshokKumaram我更新了答案。我不知道你有更多的頁面,所以這只是一些讓你開始的僞代碼。 –

+0

:i'hv更多解釋它在接下來的問題,PLZ看到我的下一個問題 我固定它爲u說,頁面重定向和再次加載,使跨度變空,我會通過一些更得到固定,但還是犯規工作.... PLZ看到它很快ň解決我的問題... –

相關問題