Click here to Skip to main content
16,021,181 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a checkboxList which is retrieve from the table of Property.
In save products, I have saved the checked of checkboxList in Product Table.
In edit products page, I want this checkbox list to be checked depending on the db values.
Posted

C#
public class CheckBoxItem
{
   public string Code { get; set; }
   public bool IsChecked { get; set; }
   public string Label {get;set;}
}

razor:
C#
<p class="checkbox" style="display:inline">
<span style="margin-left:5px;">
    @Html.HiddenFor(x => x.Code)           
    @Html.CheckBoxFor(x => x.IsChecked)
</span>
@Html.LabelFor(x => x.IsChecked, Model.Label)
</p>


see the ref.
Inputting selected checkboxes not working in MVC and Razor[^]
http://stackoverflow.com/questions/9973977/asp-net-mvc-3-retrieve-checkbox-list-values[^]
 
Share this answer
 
Comments
/\jmot 11-Feb-15 10:39am    
:Psomeone just downvote my answer.
so, please tell me why??? did the ans wrong??
if you plese tell me, then it'll help me alot.
 
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