Templates – CheckBoxList multiple options: How to model binding and get all options?

This code:

Html.CheckBoxList(ViewData.TemplateInfo.HtmlFieldPrefix, myList)

Generate this markup:


  • BD-Dist BD Name


  • SS-Dist SS Name


  • DS -Dist DS Name


  • SW-Dist SW Name

You can check multiple choices. The return string parameter Header.h_dist_cd contains only the first value selected. I What needs to be done to get the other selected values?

The post method parameters are as follows:

public ActionResult Edit(Header header)

When you have multiple items with the same name, you will use coma to separate their values

This code:

Html.CheckBoxList(ViewData.TemplateInfo.HtmlFieldPrefix, myList)

Generate this markup:


  • BD-Dist BD Name


  • SS-Dist SS Name
  • < br />

  • DS-Dist DS Name


  • SW-Dist SW Name

  • < /ul>

You can check multiple choices. The returned string parameter Header.h_dist_cd only contains the first value selected. What do I need to do to get the other selected values?

The post method parameters are as follows:

public ActionResult Edit(Header header)

When you have multiple items with the same name, you will use coma to separate their values

Leave a Comment

Your email address will not be published.