I want to implement a "Location" drop down allowing end user to select one or more locations. What is the mssql field type for storing the selections made in the field?
I have configured the dropdown:
as soon as I make a selection I get:
dotnet: warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]
Unhandled exception rendering component: Unable to cast object of type 'System.Linq.EnumerableQuery`1[System.Int32]' to type 'System.String'.
System.InvalidCastException: Unable to cast object of type 'System.Linq.EnumerableQuery`1[System.Int32]' to type 'System.String'.
You are attempting to bind DropDown with multiple selection with integer set as ValueProperty which will produce IEnumerable<int> to a string property.
Setting ValueProperty to the same as the TextPropery:
I get:
dotnet: warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]
Unhandled exception rendering component: Unable to cast object of type 'System.Linq.EnumerableQuery`1[System.String]' to type 'System.String'.
System.InvalidCastException: Unable to cast object of type 'System.Linq.EnumerableQuery`1[System.String]' to type 'System.String'.
@kest874 changing ValueProperty will not change the expected value - it’s still IEnumerable since its multi select DropDown. Maybe you should extend your model with IEnumerble property, convert to a coma separated string in the property setter and from coma separated string in the property getter.
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Reqrfepaf.Models.Sssql01
{
public partial class User
{
public IEnumerable<int> SelectedLocations
{
get
{
return Location.Split(',');
}
set
{
Location = string.Join(",", value);
}
}
}
}
I get
error CS1061: 'Location' does not contain a definition for 'Split' and no accessible extension method 'Split' accepting a first argument of type 'Location' could be found
Some background, the "Location" Field is part of the "Users" table, the locations for the drop down are in the "Locations" table.
User table has field Locations which is varchar(100)
Locations table is ID (INT) (PK) and ShortLocation varcvhar(50)
Idea was to use dropdown for the locations so that I can later use the selected locations to filter the grids (only allow the selected locations in their user record to be seen)
Still having some issues, I sent an example project with the table definition and some demo data in a text file to info@radzen.com If you could modify it to work I can modify my project to work properly.
We’ve not received your application. Use a service like Google Drive to avoid large attachments. It will be better to send us your database schema and data as SQL script.
I would like to remind you that custom implementations are not something that we usually do as part of Radzen support. Those qualify as consulting which is not something that we provide.
Totally understand, did not mean for this to come across as it was a urgent issue. I would gladly pay for consultation, I just couldn't wrap my head around how to make it work without finding an example placed somewhere. You guys are first rate with an excellent product. I wouldn't have leaned as much as I have if you guys and this forum were not such an excellent resource.