Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem With List View

Problem With List View

Scheduled Pinned Locked Moved ASP.NET
sysadminhelplearning
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    ggaurav bhandari
    wrote on last edited by
    #1

    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 pr

    P 1 Reply Last reply
    0
    • G ggaurav bhandari

      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 pr

      P Offline
      P Offline
      Parwej Ahamad
      wrote on last edited by
      #2

      Put this code in ItemDatabound event. first check item type then put that code.

      //In itemdatadatabound event
      if(e.Item.ItemType = ListViewItemType.DataItem )
      {
      Label lblTot = this.ListView1.FindControl("lblGrandTotal") as Label;
      if (lblTot != null)
      {
      lblTot.Text = totl.ToString();
      }

      Parwej Ahamad

      D 1 Reply Last reply
      0
      • P Parwej Ahamad

        Put this code in ItemDatabound event. first check item type then put that code.

        //In itemdatadatabound event
        if(e.Item.ItemType = ListViewItemType.DataItem )
        {
        Label lblTot = this.ListView1.FindControl("lblGrandTotal") as Label;
        if (lblTot != null)
        {
        lblTot.Text = totl.ToString();
        }

        Parwej Ahamad

        D Offline
        D Offline
        d0cvb
        wrote on last edited by
        #3

        I don't see lblGrandTotal label in the DOM??

        P 1 Reply Last reply
        0
        • D d0cvb

          I don't see lblGrandTotal label in the DOM??

          P Offline
          P Offline
          Parwej Ahamad
          wrote on last edited by
          #4

          Your given HTML doesn't contains that label. So where you placed that label, inside the listview or outside?

          Parwej Ahamad

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups