Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have db column string.
I can have multiple types of values stored in that field like a string or bool etc.

This column is bound using EditorFor as below :

C#
@Html.EditorFor(s => item.PropertyValue, new
                      {
                          htmlAttributes = new
                          {
                              Name = item.ItemName ,
                              @type = item.DataType
                          }
                      })



Where DataType defines the type of data that this control holds.
When the data type is checkbox, and during the Post method, from the FormsCollection, how to retrive the value?
Had the following problems :
1. If EditorFor object is used, in case of check box value false, the key is not obtained in the forms collection list at all.
2. If CheckBox object is used , then it is retriving 2 values i.e like this "true,false"

How to have a Checkbox displayed in a view dynamically and be able to retrive its value on Post from the forms collection keys.

Can some body help me with this pls?
Posted
Updated 15-Aug-15 16:19pm
v2
Comments
Have you tried CheckboxFor?

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