public
class
UserController : Controller
{
private
ForTestingEntities db =
new
ForTestingEntities();
public
ActionResult Index()
{
UserModal user =
new
UserModal();
user.MyFavoriteColors = getColorData();
return
View(user);
}
[HttpPost]
public
ActionResult Index(UserModal user)
{
return
View(user);
}
public
List<CheckBoxListHelper> getColorData()
{
List<CheckBoxListHelper> colors =
new
List<CheckBoxListHelper>()
{
new
CheckBoxListHelper {Value=1,Text=
"Red"
,IsChecked=
true
},
new
CheckBoxListHelper {Value=2,Text=
"Green"
,IsChecked=
false
},
new
CheckBoxListHelper {Value=3,Text=
"Blue"
,IsChecked=
false
},
new
CheckBoxListHelper {Value=4,Text=
"Yellow"
,IsChecked=
false
},
new
CheckBoxListHelper {Value=5,Text=
"Black"
,IsChecked=
false
},
};
return
colors;
}
}