Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. MVC 4 Radio Button List

MVC 4 Radio Button List

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netarchitecturequestionlearning
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    VishwaKL
    wrote on last edited by
    #1

    Hi, I want to develop a Survey module using MVC4, for that i have a set of questions for each questions i have 4 options & these options should be radio button in the application and all questions will be having same options EX, Agree,Disagree, Strongly agree,Strongly Disagree. How can i achieve this using MVC4. I tried several links but no link is helping out EX: Tried This[^] NOTE: I am a beginner in MVC

    R 1 Reply Last reply
    0
    • V VishwaKL

      Hi, I want to develop a Survey module using MVC4, for that i have a set of questions for each questions i have 4 options & these options should be radio button in the application and all questions will be having same options EX, Agree,Disagree, Strongly agree,Strongly Disagree. How can i achieve this using MVC4. I tried several links but no link is helping out EX: Tried This[^] NOTE: I am a beginner in MVC

      R Offline
      R Offline
      Raviranjan_Kumar_Sinha
      wrote on last edited by
      #2

      Hi Vishal, So you mean that, let say Quetion1, Question2, Question3,... and for each question you will have Option1, Option2, Option3, Option4 and for each question you will have - Agree,Disagree, Strongly agree, Strongly Disagree, Like Question1 Option1, Option2, Option3, Option4 Disagree, Agree, Strongly Agree, Strongly Disagree Question2

      Option1, Option2, Option3, Option4
      Disagree, Agree, Strongly Agree, Strongly Disagree

      ..................... Right? Thanks Raviranjan

      V 1 Reply Last reply
      0
      • R Raviranjan_Kumar_Sinha

        Hi Vishal, So you mean that, let say Quetion1, Question2, Question3,... and for each question you will have Option1, Option2, Option3, Option4 and for each question you will have - Agree,Disagree, Strongly agree, Strongly Disagree, Like Question1 Option1, Option2, Option3, Option4 Disagree, Agree, Strongly Agree, Strongly Disagree Question2

        Option1, Option2, Option3, Option4
        Disagree, Agree, Strongly Agree, Strongly Disagree

        ..................... Right? Thanks Raviranjan

        V Offline
        V Offline
        VishwaKL
        wrote on last edited by
        #3

        Hi Raviranjan, Thanks for the reply, Ya exactly i wanted and achieved it, Thanks Vishwa

        R 1 Reply Last reply
        0
        • V VishwaKL

          Hi Raviranjan, Thanks for the reply, Ya exactly i wanted and achieved it, Thanks Vishwa

          R Offline
          R Offline
          Raviranjan_Kumar_Sinha
          wrote on last edited by
          #4

          Hi Vishwa, Below i am giving idea how you can do it. In View on top @model IEnumerable--> This is basically the list of Question that you have to return from controller method Then HTML Code for Displaying the Question and their option @foreach (Question question in Model) { @Html.DisplayFor(modelItem => question.QuestionText) foreach (Option option in question.Options) { option.OptionText : @Html.RadioButtonFor(opt=>option.OptionID,option.OptionValue) } <HTML for like> Agree, DisAgree,... } The Class of Question and Option will be like below public class Option{ public int OptionID{get;set;} public string OptionText{get;set;} public string OptionValue{get;set;} } public class Question{ public string QuestionText{get;set;} public List Options{get;set;}//This will contain all 4 option } Class name and properties you can put whatever you want, i have just wrote sample. Let me know if you have any doubt. Thanks Raviranjan

          V 1 Reply Last reply
          0
          • R Raviranjan_Kumar_Sinha

            Hi Vishwa, Below i am giving idea how you can do it. In View on top @model IEnumerable--> This is basically the list of Question that you have to return from controller method Then HTML Code for Displaying the Question and their option @foreach (Question question in Model) { @Html.DisplayFor(modelItem => question.QuestionText) foreach (Option option in question.Options) { option.OptionText : @Html.RadioButtonFor(opt=>option.OptionID,option.OptionValue) } <HTML for like> Agree, DisAgree,... } The Class of Question and Option will be like below public class Option{ public int OptionID{get;set;} public string OptionText{get;set;} public string OptionValue{get;set;} } public class Question{ public string QuestionText{get;set;} public List Options{get;set;}//This will contain all 4 option } Class name and properties you can put whatever you want, i have just wrote sample. Let me know if you have any doubt. Thanks Raviranjan

            V Offline
            V Offline
            VishwaKL
            wrote on last edited by
            #5

            Thank you so much for the help. I was trying something and achieved it.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups