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

          Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

          Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

          How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page