views:

967

answers:

1

Just thinking out loud about the subject, If I have the following:

 <%= Html.EditorFor(m => m.Gender, "Gender")

And I want it to render two radio buttons:

 O Male  O Female

Assuming the class just has a string to hold the value, what would the Gender.ascx look like if we were to pass the Gender values using something like

 ViewData["Gender"] = new string[] {"Male", "Female"};
+1  A: 

This is a Radio button example (Yes No):

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%= Html.RadioButton("", "Yes") %> Yes
<%= Html.RadioButton("", "No") %> No

And another Radio Button set (Gender):

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%= Html.RadioButton("", "Male") %> Male
<%= Html.RadioButton("", "Female") %> Female

And a Drop Down Menu (Marital Status):

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%= Html.DropDownList("", new SelectList(new[] {"N/A",
    "Single", "Married", "Divorced", "Widowed" })) %>

Now I need to modify these to look for a matching ViewData[""] list of options or figure out how to pass a selection list to the partial UI Template.

Dr. Zim