Skip to content

Instantly share code, notes, and snippets.

@carloswm85
Created April 20, 2023 16:56
Show Gist options
  • Select an option

  • Save carloswm85/a08b1d13f622e1f995d185a57e81ba52 to your computer and use it in GitHub Desktop.

Select an option

Save carloswm85/a08b1d13f622e1f995d185a57e81ba52 to your computer and use it in GitHub Desktop.
How do I add Title to this SelectList? Or any other data-* HTML attribute?
public IEnumerable<SelectListItem> GetProducersSelectList()
{
SelectList selectList = new SelectList(
ProducersList
.Select(
producer =>
new
{
Text = producer.ProducerNumber + " • " + producer.Surname + ", " + producer.Name,
Value = producer.Id.ToString(),
Title = producer.BusinessName
}),
"Value",
"Text"
);
return selectList;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment