submitted from value different from what i need to print nextWhat are MVP and MVC and what is the difference?What is the difference between String and string in C#?What is the difference between const and readonly?What is the difference between a field and a property?How to return multiple values from a function?What is the difference between an abstract function and a virtual function?What is the difference between MVC and MVVM?Get int value from enum in C#MVC show Multiple Select List in View from ViewBag?How to return to controller a IEnumerable of the values selected in the view from a list

Risk of getting Chronic Wasting Disease (CWD) in the United States?

How to say job offer in Mandarin/Cantonese?

Theorem, big Paralist and Amsart

What defenses are there against being summoned by the Gate spell?

Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?

Can divisibility rules for digits be generalized to sum of digits

What do you call a Matrix-like slowdown and camera movement effect?

Which models of the Boeing 737 are still in production?

The use of multiple foreign keys on same column in SQL Server

What is the offset in a seaplane's hull?

What do the dots in this tr command do: tr .............A-Z A-ZA-Z <<< "JVPQBOV" (with 13 dots)

LaTeX closing $ signs makes cursor jump

Is it possible to do 50 km distance without any previous training?

Problem of parity - Can we draw a closed path made up of 20 line segments...

Python: next in for loop

Can I make popcorn with any corn?

Theorems that impeded progress

What are the differences between the usage of 'it' and 'they'?

Arthur Somervell: 1000 Exercises - Meaning of this notation

Languages that we cannot (dis)prove to be Context-Free

Do I have a twin with permutated remainders?

Can I ask the recruiters in my resume to put the reason why I am rejected?

Why don't electron-positron collisions release infinite energy?

What is the word for reserving something for yourself before others do?



submitted from value different from what i need to print next


What are MVP and MVC and what is the difference?What is the difference between String and string in C#?What is the difference between const and readonly?What is the difference between a field and a property?How to return multiple values from a function?What is the difference between an abstract function and a virtual function?What is the difference between MVC and MVVM?Get int value from enum in C#MVC show Multiple Select List in View from ViewBag?How to return to controller a IEnumerable of the values selected in the view from a list






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am making a modification to a large existing project



the existing project is a C# MVC project
It has a complex backend with a clearly well thought out architecture which i have been told not to change.



The Models (which do get passed to the views) are complex and one of the properties on the model is a list of people.



The list of people contains a name and an id



My task is to create a form on the front end which has a load of check boxes which list all of the people in the model.



It also needs to display a list of selected people as tabs (separate from the form)



To generate the check boxes i simply loop through the list of people and use the name as the display text and the id as the input fields value.



IN the back end (since i cant make modifications to the model) I capture the submitted data with a object and assign this objects properties to ViewBag.



Back in the front end the contents of ViewBag are used to print the list of selected people.



The problem is the ViewBag contains the ID's of the people not the Names.
(because the form submits the ID's)



At first I had a loop which prints every item in the ViewBag but this on its own only printed the ID's



To get the Names i have had to put a line in each iteration of the loop which selects a Person from the model where the id is equal to the ViewBag Value



I can then print that persons name rather than their ID



This sort of logic is the sort of thing which should go in the controller, but i cannot put the foreach loop there.



What would be a clean and appropriate way to handle this?










share|improve this question




























    0















    I am making a modification to a large existing project



    the existing project is a C# MVC project
    It has a complex backend with a clearly well thought out architecture which i have been told not to change.



    The Models (which do get passed to the views) are complex and one of the properties on the model is a list of people.



    The list of people contains a name and an id



    My task is to create a form on the front end which has a load of check boxes which list all of the people in the model.



    It also needs to display a list of selected people as tabs (separate from the form)



    To generate the check boxes i simply loop through the list of people and use the name as the display text and the id as the input fields value.



    IN the back end (since i cant make modifications to the model) I capture the submitted data with a object and assign this objects properties to ViewBag.



    Back in the front end the contents of ViewBag are used to print the list of selected people.



    The problem is the ViewBag contains the ID's of the people not the Names.
    (because the form submits the ID's)



    At first I had a loop which prints every item in the ViewBag but this on its own only printed the ID's



    To get the Names i have had to put a line in each iteration of the loop which selects a Person from the model where the id is equal to the ViewBag Value



    I can then print that persons name rather than their ID



    This sort of logic is the sort of thing which should go in the controller, but i cannot put the foreach loop there.



    What would be a clean and appropriate way to handle this?










    share|improve this question
























      0












      0








      0








      I am making a modification to a large existing project



      the existing project is a C# MVC project
      It has a complex backend with a clearly well thought out architecture which i have been told not to change.



      The Models (which do get passed to the views) are complex and one of the properties on the model is a list of people.



      The list of people contains a name and an id



      My task is to create a form on the front end which has a load of check boxes which list all of the people in the model.



      It also needs to display a list of selected people as tabs (separate from the form)



      To generate the check boxes i simply loop through the list of people and use the name as the display text and the id as the input fields value.



      IN the back end (since i cant make modifications to the model) I capture the submitted data with a object and assign this objects properties to ViewBag.



      Back in the front end the contents of ViewBag are used to print the list of selected people.



      The problem is the ViewBag contains the ID's of the people not the Names.
      (because the form submits the ID's)



      At first I had a loop which prints every item in the ViewBag but this on its own only printed the ID's



      To get the Names i have had to put a line in each iteration of the loop which selects a Person from the model where the id is equal to the ViewBag Value



      I can then print that persons name rather than their ID



      This sort of logic is the sort of thing which should go in the controller, but i cannot put the foreach loop there.



      What would be a clean and appropriate way to handle this?










      share|improve this question














      I am making a modification to a large existing project



      the existing project is a C# MVC project
      It has a complex backend with a clearly well thought out architecture which i have been told not to change.



      The Models (which do get passed to the views) are complex and one of the properties on the model is a list of people.



      The list of people contains a name and an id



      My task is to create a form on the front end which has a load of check boxes which list all of the people in the model.



      It also needs to display a list of selected people as tabs (separate from the form)



      To generate the check boxes i simply loop through the list of people and use the name as the display text and the id as the input fields value.



      IN the back end (since i cant make modifications to the model) I capture the submitted data with a object and assign this objects properties to ViewBag.



      Back in the front end the contents of ViewBag are used to print the list of selected people.



      The problem is the ViewBag contains the ID's of the people not the Names.
      (because the form submits the ID's)



      At first I had a loop which prints every item in the ViewBag but this on its own only printed the ID's



      To get the Names i have had to put a line in each iteration of the loop which selects a Person from the model where the id is equal to the ViewBag Value



      I can then print that persons name rather than their ID



      This sort of logic is the sort of thing which should go in the controller, but i cannot put the foreach loop there.



      What would be a clean and appropriate way to handle this?







      c# model-view-controller model coding-style viewbag






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 9 at 2:30









      megamanmegaman

      3231514




      3231514






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073445%2fsubmitted-from-value-different-from-what-i-need-to-print-next%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073445%2fsubmitted-from-value-different-from-what-i-need-to-print-next%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

          2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

          Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme