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.

Blazor form component InputSelect should support binding of type Guid

See original GitHub issue

Is your feature request related to a problem? Yes.

Following code does not work if binding Type is Guid. The runtime error in browser console is `InputSelect does not support the type Guid"

// ItemCreate.razor
...
<InputSelect bind-Value="Item.CategoryId">
  @foreach(var cat in Categories) {
    <option value="cat.Id">@cat.Name</option>
  }
</InputSelect>
...
// Entities.cs
...
public class Item
{
  public Guid Id { get; set; }
  public string Name { get; set; }
  public virtual Category Category { get; set; }
  [ForeignKey("Category")]
  public Guid? CategoryId { get; set; }
}

public class Category
{
  public Guid Id { get; set; }
  public string Name { get; set; }
}
...

Describe the solution you’d like

InputSelect should support binding for type Guid.

Describe alternatives you’ve considered

I have to create custom MyInputSelect on top of InputSelect which supports Guid.

Additional context

Asp.Net Core 3 Preview 4 Browser: Chrome @version:73

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:14
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

11reactions
cmoncurecommented, Nov 7, 2019

Guid (or UUID) is used by every modern web app on the face of the planet. It should have first class support everywhere it’s possible to use it.

Currently this has to be worked around by adding redundant properties to your model and explicitly invoking Convert on the getter and setter every time you want to use InputSelect based on an object’s Guid.

`

class Model : MyObject 
{
    public string MyUidAsString { get; set; }

    override public Guid MyUid
    {
        get { return Guid.TryParse(MyUidAsString, out Guid g) ? g : default; }
        set { MyUidAsString = Convert.ToString(value); }
    }
}

`

This is frustrating and tedious. Not Blazing!

6reactions
Eirenarchcommented, Feb 12, 2020

I am really curious about the thought process behind only supporting string and enum. It is obvious to me that the integer types, guid and their nullable versions should also be supported

Read more comments on GitHub >

github_iconTop Results From Across the Web

InputSelect does not support the type System.Int32
This is one of the common error you will encounter when binding a select element to integer. Blazor Select Example. InputSelect does not...
Read more >
ASP.NET Core Blazor data binding
This article explains data binding features for Razor components and DOM elements in Blazor apps. Razor components provide data binding ...
Read more >
How to make InputSelect support more types
If you have used InputSelect in Blazor in ASP.NET Core 3.1 you may have noticed bind-Value only works on a limited set of...
Read more >
Create an InputSelect component that accepts lists with ...
My goal is to send a list of any type to InputSelect while @typeparam is used for binding. c# · asp.net-core · blazor...
Read more >
Blazor Binding Support Multiple Options For - 'Select' ...
In this article, we will explore the blazor application binding support multiple options for the 'Select' or 'InputSelect' which is .
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