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.

Select is not binding

See original GitHub issue

I have placed select code on the out-of-box Blazer-Client/Server project’s client for a select control and it is not binding. Note all other control types (textbox, checkbox, etc) on the same page are binding correctly. Is my syntax correct?

To Reproduce

Index.razor file

Index.razor file

@page "/"

<select bind="@testing">
    <option value="Unknown">Unknown</option>
    <option value="Male">Male</option>
    <option value="Female">Female</option>
    <option value="Other">Other</option>
</select>

@functions {
    string testing { get; set; } = "Female";
}

### Expected behavior
Female value is showing in select control. Currently Unknown is showing.

### Additional context
Project Type: Blazor Client-Server
Visual Studio 16.1.0 Preview 2
Microsoft.AspNetCore.Blazor 3.0.0-preview4-19216-03
Microsoft.AspNetCore.Blazor.Build 3.0.0-preview4-19216-03
NETStandard.Library 2.0.3

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rjmr97commented, Apr 24, 2019

I don’t know if it the select binding is supposed to work with strings/int/etc., but it does work with enums:

<select bind="@testing">
    <option value="@testingEnum.Unknown">Unknown</option>
    <option value="@testingEnum.Male">Male</option>
    <option value="@testingEnum.Female">Female</option>
    <option value="@testingEnum.Other">Other</option>
</select>


@functions {
    enum testingEnum { Unknown, Male, Female, Other };
    testingEnum testing { get; set; } = testingEnum.Female;
}

image

0reactions
SteveSandersonMScommented, Jun 27, 2019

I see - this is a duplicate of https://github.com/aspnet/AspNetCore/issues/5616, so will close in favour of that one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

select ngmodel not binding the variable - angular
I think you're missing the use of the ngValue directive here to have the object reflected in the value bound to ngModel ....
Read more >
Mat-Select not binding value : r/angular
Mat-Select not binding value. Hi all! I;m trying to create a form where I use mat select: HTML: <ng-template #content let-modal> <div ...
Read more >
Angular Select List Value not binding with Static Values
In my case I ran into a problem with static list values binding to a non-string value which caused the binding to effectively...
Read more >
ng-model not binding <select> list values in 1.4.rc2 #11890
I have a list of static values that are bound to a list and I'm trying to get the list to display the...
Read more >
AngularJS: API: select
HTML select element with AngularJS data-binding. ... To bind the model to a non-string value, you can use one of the following strategies:....
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