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

  • SEARCH
  • Home
  • 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 6528143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:30:26+00:00 2026-05-25T09:30:26+00:00

Hi all i’ve currently got a list of telephone numbers being output using:- Controller:-

  • 0

Hi all i’ve currently got a list of telephone numbers being output using:-

Controller:-

public ActionResult ViewSubRange(int id)
{
    IEnumerable<Number> numbers = context.Numbers.Where(m => m.RangeID == id).ToList();

    return View("SubRange", numbers);
}

View:-

@model IEnumerable<TelephoneNumberManagement.Models.Number>
<table>
    <tr>
        <th>
            Number
        </th>
        <th>
            Status
        </th>
    </tr>

@foreach (var item in Model)
{
    <tr> 
        <td>@item.Number1</td>
        <td>@item.Status.StatusName</td>
    </tr> 

}

</table>

This is fine, however i’ve noticed that we can have a lot of numbers being output. I was wondering if its possible to group the numbers, so for example by Customer. So what i want to achieve is something like:-

01132210000-01132210999 CUSTOMER A

01132211000-01132211009 CUSTOMER B

01132211010-01132211029 CUSTOMER C

  • 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-25T09:30:27+00:00Added an answer on May 25, 2026 at 9:30 am

    You could define a new view model:

    public class MyViewModel
    {
        public string StatusName { get; set; }
        public string Numbers { get; set; }
    }
    

    and then group by customer name:

    public ActionResult ViewSubRange(int id) 
    {
        var numbers = context.Numbers
            .Where(m => m.RangeID == id)
            .GroupBy(x => x.Status.StatusName)
            .Select(x => new MyViewModel
            {
                StatusName = x.Key,
    
                // TODO: could change the format if you will or
                // select the min and max or whatever you need
                Numbers = string.Join("-", x.Select(n => n.Number1)) 
            })
            .ToList();
        return View(numbers);
    }
    

    and finally in your view:

    @model IEnumerable<MyViewModel>
    <table>
        <tr>
            <th>Number</th>
            <th>Status</th>
        </tr>
    
        @foreach (var item in Model)
        {
            <tr> 
                <td>@item.Numbers</td>
                <td>@item.StatusName</td>
            </tr> 
        }
    </table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All it does is output 'CHECK' which I put in to make sure it
All the examples I've come across using Google Maps API seem to show a
All of the examples I've seen of using yield return x; inside a C#
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
All, I am building a small site using PHP. In the site, I receive
All the day numbers and week days on twitter bootstrap date picker show up
All, I'm using wordpress with this and for some reason the eventDrop stopped working.
All I need is to create a file that contains a file names' list
All, I'm using Facebook Connect (JS SDK) to authenticate a user to my site.
All right, so I've got an applet I'm trying to embed into an HTML

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.