Click here to Skip to main content
15,891,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
In mvc i want to Dynamic check/uncheck checkbox in MVC.I use following code
C#
@if (Model.DocumentSearchTypes != null)
{
    @Html.CheckBox("Documents",true)
}
else
{
    @Html.CheckBox("Documents",false)
}

It is working , but how can i optimize it by using just one If --Else condition.
Posted
Updated 9-May-12 22:35pm
v2
Comments
Sandeep Mewara 10-May-12 4:36am    
Am I reading it wrong here - I see only ONE if-else. What is your issue?

1 solution

Got Solution....

HTML
@Html.CheckBox("Documents",@Model.DocumentSearchTypes != null ? true : false)
 
Share this answer
 
v2
Comments
member60 15-May-12 0:49am    
5!

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