Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1082081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:15:04+00:00 2026-05-16T22:15:04+00:00

I have the following that will enumerate over the model and add an invoice

  • 0

I have the following that will enumerate over the model and add an invoice and a date.
Then under that I want to have a table with the line items for that invoice that is collapsible for each invoice. I am not sure how to do this while enumerating over the model, I don’t know how to uniquely ID the table, then I am not sure how to tell the jquery function which table we need to hide.

here is the code I have now. I added a comment next to the table I am wanting to hide. There is an anchor tag above it that calls the javascript function in which is the jquery hide function is

 <table class="themedtable"
    cellspacing="0">
    <tr>
        <th style="text-align: left">
            Invoice
        </th>
        <th>
            Order Date
        </th>
    </tr>
    <% foreach (var item in Model)
       { %>
    <tr>
        <td style="text-align: left">
            <strong>
                <%=Html.Encode(item.Invoice)%></strong>
        </td>
        <td>
            <%=Html.Encode(String.Format("{0:d}",item.invcte))%>
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <a href="javascript:toggletable()">Show/Hide Table</a>
        </td>
    </tr>
    <%if (item.LineItemList.Count > 0)
   { %>
    <tr>
        <td>
            <table style="margin-left: auto; margin-right: auto; width: 90%" cellspacing="0">  //this is the table i need to id and collapse when the above link is clicked
                <tr>
                    <th>
                        Part
                    </th>
                    <th>
                        Desc
                    </th>
                    <th>
                        Qty
                    </th>
                    <th>
                        Qty Shipped
                    </th>
                    <th>
                        Status
                    </th>
                </tr>
                <%foreach (var lineItem in item.LineItemList)
                    { %>
                <tr>
                    <td style="width: 10%">
                        <%=Html.Encode(lineItem.Partno) %>
                    </td>
                    <td style="width: 50%">
                        <%=Html.Encode(lineItem.Description) %>
                    </td>
                    <td style="width: 10%">
                        <%=Html.Encode(lineItem.Qty) %>
                    </td>
                    <td style="width: 20%">
                        <%=Html.Encode(lineItem.QtyShipped) %>
                    </td>
                    <td style="width: 10%">
                        <%=Html.Encode(lineItem.Status) %>
                    </td>
                </tr>
                <%} %>
            </table>
        </td>
    </tr>
    <%} %>
    <%} %>
</table>

<script type="text/javascript">
    function toggletable() {
        $(//selector).hide();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:15:05+00:00Added an answer on May 16, 2026 at 10:15 pm

    Here are my two cents worth. I think you may be approaching this in a manner that will make life hard for you.

    What I’d do is the following.

    1. Add your invoices if you like and
      attach a click event to them.
    2. On click of the invoice, do an Ajax
      postback, using jQuery, to get the
      line items.
    3. Your ActionResult should then grab
      those line items, pass them to a
      PartialView and return the
      PartialView back to the client.
    4. Then in your Success jQuery Ajax
      method, you replace the contents of
      a div with the returned HTML.

    This saves potentially a lot of data on the page and also makes it look quite neat.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code that will rotate a drawable by a set amount
I’m after some C# code that will have the following methods that will return
I have been trying to write a regex that will remove whitespace following a
I am parsing some XML that will have a link such as the following
I have a method that I will use in the following contexts: 1. User
I have the following function. The problem is that the $lang variable will vary
I know that using the following codes will make each column have unique values,
I have a project that requires the following. Four arrays will be declared in
I have the following PowerShell script that will parse some very large file for
I currently have the following that will search a field within my db for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.