Click here to Skip to main content
15,917,601 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using ASP.Net MVC with C# language.
I would like to edit a user. The user table has a boolean field called "IsActive".
In the model, I'm using ADO.Net Entity Data Model.
C#
public ActionResult Edit(int id) {
    var editUser = (from u in userEntity.USERs where u.UserId == id select u).First();
    return View(editUser);
}

In the view, script generate by Visual Studio for IsActive is using TextBox.
HTML
<%= Html.TextBoxFor(model => model.Activate) %>

In this case, I would like to use RadioButton instead with the options Yes and No.
How to do it?
Thanks!
Posted

C#
<![CDATA[<%= Html.RadioButtonFor(model => model.Active, true) %>]]> Yes
<![CDATA[<%= Html.RadioButtonFor(model => model.Active, false) %>]]> No
 
Share this answer
 
Comments
Bun Leap_kh 12-Feb-12 20:49pm    
I've tried it, but it doesn't show Radio button, it shows "]]> Yes ]]> No".
Try the below... It should work.

model.Activate, true) %>]]> Yes
model.Activate, false) %>]]> No
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900