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 9218735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:55:56+00:00 2026-06-18T02:55:56+00:00

In my project we allow users to sign up to different subscription tariffs which

  • 0

In my project we allow users to sign up to different subscription tariffs which allow for different functionality. Some users are on free subscriptions and as such will only have limited features, while paying users are able to perform extra actions with their account. This functionality is still to be implemented, but I am creating a view for details of the tariffs.

I have a “SubscriptionTariffs” table and a “SubscriptionServices” table, with the latter holding a foreign key to the ID field of the former for each service. In my view I want to display all possible services, regardless of whether the tariff supports them or not. If they are available on that tariff, I want a checkbox to be checked, and vice versa.

So for a free tariff, I would want something like the following to be displayed where the first seven options are displayed as ticked, and the others unmarked but still displayed:

            <tr><td style="padding:5px;"><input type="checkbox" DISABLED checked />&nbsp; @Language.ViewTransactions</td></tr>
            <tr><td style="padding:5px;"><input type="checkbox" DISABLED checked />&nbsp; @Language.CreateTransactions</td></tr>
            <tr><td style="padding:5px;"><input type="checkbox" DISABLED checked />&nbsp; @Language.Announcements</td></tr>
            <tr><td style="padding:5px;"><input type="checkbox" DISABLED checked />&nbsp; @Language.Alerts</td></tr>
            <tr><td style="padding:5px;"><input type="checkbox" DISABLED checked />&nbsp; @Language.Foldering</td></tr>
            <tr><td style="padding:5px;"><input type="checkbox" DISABLED checked />&nbsp; @Language.TransactionDownload</td></tr>
            <tr><td style="padding:5px;"><input type="checkbox" DISABLED checked />&nbsp; @Language.TransactionUpload</td></tr>
            <tr><td style="padding:5px;"><input type="checkbox" DISABLED checked />&nbsp; @Language.EZApproval</td></tr>
            <tr><td style="padding:5px;"><input type="checkbox" DISABLED />&nbsp; @Language.SupplyChainFinance</td></tr>
            <tr><td style="padding:5px;"><input type="checkbox" DISABLED />&nbsp; @Language.HierarchicalOrgs</td></tr>
            <tr><td style="padding:5px;"><input type="checkbox" DISABLED />&nbsp; @Language.WhiteLabeling</td></tr>
            <tr><td style="padding:5px;"><input type="checkbox" DISABLED />&nbsp; @Language.MultiFormatDownload</td></tr>
            <tr><td style="padding:5px;"><input type="checkbox" DISABLED />&nbsp; @Language.MultiFormatUpload</td></tr>
            <tr><td style="padding:5px;"><input type="checkbox" DISABLED />&nbsp; @Language.VANInteroperability</td></tr>

I have written the following to display all the associated services to a tariff:

        @{
            foreach (var SubscriptionService in this.Model.SubscriptionServices)
            {
                <tr><td style="padding:5px;"><input type="checkbox" DISABLED checked />&nbsp; @(SubscriptionService.ServiceName != null ? SubscriptionService.ServiceName : "")</td></tr>
            }
        }

This works fine, but I need to display all services and check or uncheck them as necessary.

I would be extremely grateful if someone could point me in the right direction, I assume I should be able to write an if-else statement or something to check, but I’m not entirely sure.

  • 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-06-18T02:55:57+00:00Added an answer on June 18, 2026 at 2:55 am

    presumably in this example this.Model.SubscriptionServices are the services which are held under the chosen tariff so you only need to add the unchecked checkboxes.

    The easiest place to do this would be in your model, you should add another collection for all subscription services, then in your view you could write:

    @{
        foreach (var SubscriptionService in this.Model.SubscriptionServices)
        {
            <tr><td style="padding:5px;"><input type="checkbox" DISABLED checked />&nbsp; @(SubscriptionService.ServiceName != null ? SubscriptionService.ServiceName : "")</td></tr>
        }
        foreach (var SubscriptionService in this.Model.AllSubscriptionServices.Where( s => !this.Model.SubscriptionServices.Contains( s ) ) )
        {
            <tr><td style="padding:5px;"><input type="checkbox" DISABLED />&nbsp; @(SubscriptionService.ServiceName != null ? SubscriptionService.ServiceName : "")</td></tr>
        }
    }
    

    alternatively, applying this where clause in your model would be more efficient as less data would be sent to the View, more efficient still, if you’re using LINQ to SQL or some other ORM to access your data model (and passing those models directly to the view) then you can add a boolean to the generated partial class: public bool IsInSelectedTarriff { get; set; } then write a more complex query to fill your Model.SubscriptionServices collection:

    this.SubscriptionServices = (
        from sub in DataContext.SubscriptionServices
        select new SubscriptionServices()
        {
            ID = ID,
            ServiceName = ServiceName,
            // copy all data directly into it's field
            // ...
            IsInSelectedTarriff = sub.SubscriptionTarriffID == this.SubscriptionTarriff
        } );
    

    You should note though that if this model is used in another view, best practice would have you create a new ViewModel for the SubscriptionTarriff specific to that screen which is a direct copy of the properties in the original with the added IsInSelectedTarriff option. The Tuple class is also helpful for appending additional data to collections.

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

Sidebar

Related Questions

I'm about to start a new project which would allow users to navigate through
In my project, a wcf restful service, which allow users to upload photos to
I'm working on a project using Google Maps v3 that will allow users to
I'm about to add a feature to my project that will allow users to
I'm currently working on a project in Java, that will allow users to type
Ok, so I'm working on a project that will allow users to record themselves
In my project (iPhone app) I have a nice webview to allow users to
So I'm trying to add some ability to my project to allow user-defined properties
I'm working on a java project that will allows users to parse multiple files
I'm working on a Rails project where I want to allow users to create

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.