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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:19:35+00:00 2026-06-13T23:19:35+00:00

In this project we have two list, one for the dealer and the second

  • 0

In this project we have two list, one for the dealer and the second for his products.

So far if you check one dealer we get back all the product for this specific dealer, it implemented in javascript (Json).

Html (5 🙂

@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
    <legend>DealerProduct</legend>

     <div class="editor-label">
        @Html.LabelFor(model => model.DealerID)
    </div>
    <div class="editor-field">
        @Html.DropDownList("DealerID", String.Empty)
        @Html.ValidationMessageFor(model => model.DealerID)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.ProductID)
    </div>
    <div class="editor-field">

        @Html.DropDownList("ProductID", String.Empty)
        @Html.ValidationMessageFor(model => model.ProductID)
    </div>
    <p>
        <input type="submit" value="@Shared.Add" />
    </p>
</fieldset>
}

JavaScript (Json 🙂

<script type="text/javascript">
$(document).ready(function() 
 {
  $("#DealerID").change(function ()
  {
       var self = $(this);
       var items="";
       var url = "";
       url = "@Url.Action("GetDealerProducts","DealerProduct")/"+self.val();
       $.ajaxSetup({ cache: false });
        $.getJSON(url,function(data)
        {   
          $.each(data,function(index,item)
          {
            items+="<option value='"+item.Value+"'>"+item.Text+"</option>\n";
          });
          $("#ProductID").html(items);
           $.ajaxSetup({ cache: true }); 
        });
    });       
 });
</script>

Controller :

public ActionResult GetDealerProducts(int id)
    {
        Dealer currentDealer = db.Dealers.Single(p => p.UserName == User.Identity.Name);
        Dealer subDealer = db.Dealers.Single(s => s.DealerID == id);


        List<Product> productOpenToSale = new List<Product>();

        foreach (var item in currentDealer.ProductToSale)
            if (!subDealer.ProductToSale.ToList().Exists(e => e.ProductID == item.ProductID))
                productOpenToSale.Add(item.Product);

        List<SelectListItem> productOpenToSaleList = new List<SelectListItem>();
        productOpenToSale.ForEach(item => productOpenToSaleList.Add(new SelectListItem { Value = item.ProductID.ToString(), Text = item.ProductName }));

        return Json(productOpenToSaleList, JsonRequestBehavior.AllowGet);
    }

What I really need is adding (a pairing of) products dealer, which he can sell in the future.

Current option is to add products one by one, the desire is to give the possibility of multiple selection of all products.

Maybe something like dynamic checkBoxList or an foreach on a List from the ViewModel who add input – checkbox like this, but I don’t know how to fill it after the dealer has selected on the first list and receive all the selected product back on submit..

10X for any help!! (&& sorry for my bad English 🙂

  • 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-13T23:19:36+00:00Added an answer on June 13, 2026 at 11:19 pm

    you can change this line of code

    @Html.DropDownList("ProductID", String.Empty)
    

    with something like this

    <select id="SelectedItemIds" multiple="multiple" name="SelectedItemIds">
    

    and having a viewModel on the server like this

    class MyViewModel
    {
        public int[] SelectedItemIds { get; set; }
        public int DealerID {get;set;}
    }
    

    and having a controller like this

        [HttpPost]
        public ActionResult Index(MyViewModel myViewModel)
        {
            return View();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two entities, a project and a company. One company has a list
My use case is this... I have a project that has two production branches.
I have two versions of a project. One for Silverlight and one for .NET.
I have two tables, one is a list of songs. The other is a
OK, so I have two (completely unrelated, different project) classes using iterators now. One
In my project, I have two Core Data entities. One is the grouping (can
I've two classes: User and Project. The project class have ONE user (the owner
I have two sheets. One that lists all of my projects with columns for
i have created a java project in eclipse,in this project i have an html
I have been developing a project and in this project i have designed my

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.