question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SelectList for DropDown Functionality

See original GitHub issue

Hi, how can we support a SelectList with your lib,

public IEnumerable<SelectListItem> Creating_a_select_list(State selected)
{
    return State.GetAll().Select(
        x => new SelectListItem
        {
            Selected = x == selected,
            Text = x.Description,
            Value = x.Value.ToString()
        });
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
TylerBrinkleycommented, Jan 21, 2018

@weedkiller Enums.GetValues<DaysOfWeek>(EnumMemberSelection.Flags) would return Sunday through Saturday.

@jnm2 If you want all values of the enum with exactly one bit set see above. If you have a value and want to split it out into a list of flags with exactly one bit set you would call the GetFlags extension method.

1reaction
TylerBrinkleycommented, Jan 5, 2018

Not sure, I don’t use much MVC. Maybe something like this?

public IEnumerable<SelectListItem> Creating_a_select_list(State selected)
{
    return Enums.GetMembers<State>().Select(
        x => new SelectListItem
        {
            Selected = x.Value == selected,
            Text = x.AsString(EnumFormat.Description),
            Value = x.AsString()
        });
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

ASP.NET MVC Dropdown List From SelectList
It looks like I am giving it a valid set of SelectListItem s in what should be a pretty straightforward dropdown list, but...
Read more >
Using the DropDownList Helper with ASP.NET MVC
This tutorial will teach you the basics of working with the DropDownList helper and the ListBox helper in an ASP.NET MVC Web application....
Read more >
Create DropDownList using HtmlHelper in ASP.Net MVC
This tutorial explains how to create DropDownList using html helper in razor view in asp.net MVC. HtmlHelper class include two extension methods to...
Read more >
Select Lists in a Razor Pages Form
Select lists or DropDown lists are used in a Razor Pages form to enable users to select zero or more predefined options.
Read more >
Different Ways Of Binding Razor DropdownList In ASP.NET ...
In this article, I will demonstrate the simple ways to populate a DropDownList using ViewBag, ViewData, TempData, jQuery, Model, Database, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found