|
In totl i got total price but i am not able to display it... Loop is not go in Else Loop.............
<asp:ListView ID="lstViewCart_History" runat="server" OnPreRender="lstViewCart_History_PreRender" OnItemDataBound="lstViewCart_History_OnItemDataBound" ItemPlaceholderID="PlaceHolder1">
<LayoutTemplate>
<table width="40%">
<thead>
<tr>
<td>
<%# Eval("order_pid")%>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</thead>
<tbody>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</tbody>
<tr>
<td colspan="8" align="right">
Total Amount
</td>
<td colspan="2" align="left"><br />
$<asp:Label ID="lblw" runat="server" Text=""></asp:Label>
</td>
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<table>
<tr>
<td>
<table>
<tr>
<td>
Book Name
</td>
<td>
Author
</td>
<td>
ISBN
</td>
<td>
Order Number
</td>
<td>
Order Date
</td>
<td>
Quantity
</td>
<td>
Price
</td>
<td>
Total Price
</td>
</tr>
<tr>
<td>
<%# Eval("cartdetail_pname")%>
</td>
<td>
<%# Eval("cartdetail_author")%>
</td>
<td>
<%# Eval("cartdetail_isbn")%>
</td>
<td>
<%# Eval("order_pid")%>
</td>
<td>
<%# Eval("order_date")%>
</td>
<td>
<%# Eval("cartdetail_qty")%>
</td>
<td>
$<%# Eval("cartdetail_price")%>
</td>
<td>
$<asp:Label runat="server" ID="total_price" Text='<%#Eval("total_price")%>'></asp:Label>
</td>
</tr>
</table>
</td>
</tr>
</table>
</ItemTemplate>
</asp:ListView>
protected void lstViewCart_PreRender(object sender, EventArgs e)
{
Label lblTot = this.ListView1.FindControl("lblGrandTotal") as Label;
if (lblTot == null)
{
}
else
{
lblTot.Text = totl.ToString();
}
}
Thanks for giving time to read my problem and also for your valuable suggestions.
Gaurav Bhandari
|
|
|
|
|
Put this code in ItemDatabound event. first check item type then put that code.
if(e.Item.ItemType = ListViewItemType.DataItem )
{
Label lblTot = this.ListView1.FindControl("lblGrandTotal") as Label;
if (lblTot != null)
{
lblTot.Text = totl.ToString();
}
Parwej Ahamad
|
|
|
|
|
I don't see lblGrandTotal label in the DOM??
|
|
|
|
|
Your given HTML doesn't contains that label. So where you placed that label, inside the listview or outside?
Parwej Ahamad
|
|
|
|