I'm trying to hook up a RadioButtonList to store data against a field in our database (that is varchar). Radzen picked this field up as a string (as it should). As far as I can see the RadioButtonList is wired up to the database as an integer (the values section of each item in the list). I'm sure there is a way to configure it, and I'm probably missing something simple. Any help would be appreciated.
RadioButtonList Value depends on what you have in RadzenRadioButtonListItem Value and TValue.
Thanks, I ended up adding an "Attribute" to the RadioButtonList: Name=TValue and Value=string in order to save the strings to the database fields. I also made variables to store the text and placed that in the "Items" section.
@enchev I for one have never been able to get this to work (Selectbar as well) with any values that are not INTs or bools. I'm sure I'm just misunderstanding, and that's why your radio demo's are limited to INTs.
But with -
I get this -
My workaround is to assign the string values to variables on page load, then use the variables as the item values.
@enchev Another issues with Radio Button lists is that Radzen confuses integers and bools. To reproduce, use an integer type like tinyint, and set the TValue to byte. Set the value of one item to 1, and the other to 0. In design and runtime Radzen will set the 0 item to selected.
Change the 0 item to a 2. Radzen no longer automatically selects any of the items.
This one's actually a bit of a showstopper for me. It appears to end users that some radio buttons have preselected values without reason.
To your first question: this is how Razor parser works with strings. Here is how to set string literals:
For non nullable numeric types 0 is the default value so you might need to use nullable numeric.
@enchev good to know, thank you so much!