From 0088c3531d95664905693b8f0e19f6e4f8e86a88 Mon Sep 17 00:00:00 2001 From: Julien Marpault Date: Wed, 4 Mar 2020 13:45:29 +0100 Subject: [PATCH] Support int in InputSelect.cs Add support to int type for inputSelect --- src/Components/Web/src/Forms/InputSelect.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Components/Web/src/Forms/InputSelect.cs b/src/Components/Web/src/Forms/InputSelect.cs index b8cdbeab1f4e..cf9ee8733d62 100644 --- a/src/Components/Web/src/Forms/InputSelect.cs +++ b/src/Components/Web/src/Forms/InputSelect.cs @@ -54,6 +54,17 @@ protected override bool TryParseValueFromString(string value, out TValue result, return false; } } + else if (typeof(TValue)== typeof(int)) + { + if(int.TryParse(value, out int parsedValue) + { + result=parsedValue; + validationErrorMessage = null; + return true; + } + validationErrorMessage="Impossible to convert value to int"; + return false; + } throw new InvalidOperationException($"{GetType()} does not support the type '{typeof(TValue)}'."); }