-1

I have database table T_HD_FUNC with 3 fields: FUNC_ID, FUNC_NAME and SYS_ID. In the controller I have some code below:

ViewBag.FUNC_ID = new SelectList(db.T_HD_FUNC.OrderBy(d => d.SORT), "FUNC_ID", "FUNC_NAME", "SYS_ID");

Inside the view I have some code below:

@Html.DropDownList("FUNC_ID", (IEnumerable<SelectListItem>)ViewBag.Area_ID, "Select menu", new { @class = "form-control" })

The result: display value and Name like this image below

But sometime, We want display to display more than one field attribute. In this case I want display attribute filterid for column SYS_ID like this.

<option value="1" filterid = "1">Style master</option>
<option value="2" filterid = "2">Styles Development</option>
<option value="7" filterid = "1">Style Listing Gallery</option>

How can I achieve like this? Thanks

Hong Van Vit
  • 2,884
  • 3
  • 18
  • 43
  • You cant - the `DropDownList()` method only generates a value attribute and the text based oneach `SelectListItem` (and that's invalid html anyway). Explain why you want to do this. –  Jun 20 '17 at 08:04
  • Possible duplicate of [Add attribute to select list option](https://stackoverflow.com/questions/11285303/add-attribute-to-select-list-option) – adiga Jun 20 '17 at 09:38

1 Answers1

0

using this:

$('yourElement').attr("yourAttribute", yourValue)