Binding radio button selection to entityhttp://forums.asp.net/t/1798135.aspx/1?Binding+radio+button+selection+to+entityMon, 30 Apr 2012 01:53:41 -040017981354956576http://forums.asp.net/p/1798135/4956576.aspx/1?Binding+radio+button+selection+to+entityBinding radio button selection to entity <p>I have 2 radio buttons in my view:</p> <pre class="prettyprint">&lt;input type=&quot;radio&quot; name=&quot;gender&quot; id=&quot;female&quot; /&gt;Female &lt;input type=&quot;radio&quot; name=&quot;gender&quot; id=&quot;male&quot; /&gt;Male</pre> <pre class="prettyprint">How do I get the option the user selected in my controller? I did something like</pre> <pre class="prettyprint">public ActionResult GenderView(string male, string female) { }</pre> <pre class="prettyprint">but those variables were always null. How do I read the selection from the controller?</pre> 2012-04-29T04:49:48-04:004956591http://forums.asp.net/p/1798135/4956591.aspx/1?Re+Binding+radio+button+selection+to+entityRe: Binding radio button selection to entity <p>check this link this may help you out</p> <p><a href="http://stackoverflow.com/questions/1874845/asp-net-mvc-two-way-data-binding-of-model-to-radio-button-list-using-typed-model">http://stackoverflow.com/questions/1874845/asp-net-mvc-two-way-data-binding-of-model-to-radio-button-list-using-typed-model</a></p> 2012-04-29T05:35:23-04:004957082http://forums.asp.net/p/1798135/4957082.aspx/1?Re+Binding+radio+button+selection+to+entityRe: Binding radio button selection to entity <p>I dont get it. I guess I dont need it to bind, but maybe just get the selected value of the input from the controller, is that possible?</p> 2012-04-29T17:12:04-04:004957175http://forums.asp.net/p/1798135/4957175.aspx/1?Re+Binding+radio+button+selection+to+entityRe: Binding radio button selection to entity <p>when a radio button is posted, like all form elements, it sends its name &amp; value. normal html form convention is that you woudl give the radio button the same names (to make then mutually exclusive) and give then unique values, so the server can determine which one was checked. if you folowed this convention, then in mvc for the parameter (or model property) gender, the value would be the value of the checked radio button. just add value attributes to your radio buttons.</p> <p>note: in you case as you don't supply a value, there is none posted back.</p> 2012-04-29T20:52:30-04:004957271http://forums.asp.net/p/1798135/4957271.aspx/1?Re+Binding+radio+button+selection+to+entityRe: Binding radio button selection to entity <p>worked, thanks!!</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;input type=&quot;radio&quot; name=&quot;gender&quot; id=&quot;female&quot; value=&quot;female&quot; /&gt;Female</p> <pre class="prettyprint">&lt;input type=&quot;radio&quot; name=&quot;gender&quot; id=&quot;male&quot; value=&quot;male&quot;/&gt;Male</pre> <pre class="prettyprint">public ActionResult GenderView(string gender)</pre> <pre class="prettyprint"> { }</pre> 2012-04-30T01:53:41-04:00