Populate a text box indexed from a listbox selection

Hello, I hope that you can help me. Firstly, I think that Radzen is an amazing tool and have got a fully working CRUD example based on my SQL DB with very little effort. I now need to progress the App by adding functionality and I admit that most of my issues are due to very poor C# skills. I am on a very steep learning curve here!

I have tried for what seems like days to do what should be a very simple thing. I have a dropdown list created as part of my SQL Scaffolding (Foreign Field on Species_ID both tables) which I have set-up to pull a list from a SQL table - [SpeciesList]. The edit form is for adding new entries to another table (model) for [SpeciesSightingRecord] two values of which are being picked up from the Species list. This works well and I can select [BinomialName] from the drop down list and have it saved back to the DB. However, there is a second field [CommonName] that is from the same SQL result (row) and I want to have a text box on the form updated based on the list selection. So, pick a Binomial Name from the list box and if a Common Name exists in the same row, have it populate a text box, I have tried numerous examples based on other requests on the forum but cannot get it to work. I tried following your example (orderdetail.Product = getProductsResult.FirstOrDefault(p => p.ProductID == ${event})) by modifying to suit but I keep getting implicit conversion errors and all sorts of other things depending on what I have tried. Seems like the OnChange args are not compatible with what I am trying to do = e.g. String to int etc... Any chance that you could explain the best way to do this. Maybe, as it is only two tables, the solution is more straight forward? I was hoping to learn by doing but have reached a total dead end. This would be much appreciated as I am a volunteer at a charity trying to 'help out' with an old legacy Access database that needs bringing into the 21st Century! I have the SQL knowledge but am not a web / C# programmer. Many thanks...

Hi @Codmental,

You need to set the Value property of the TextBox to some expression which depends on the Value of the DropDownList. More info is available in the documentation: Properties (Blazor)
Expressions (Blazor)
The Value of the TextBox should be a string property.

What did you try and how did it fail?

What example are you referring to? What is the actual compiler error?

I don't understand this requirement.

1 Like

Hi, thanks for the reply. I have played around some more and it turns out that what actually I needed was two dropdown data grids, both linked to the same Data source (by ID) but with different column names. This then works ‘out of the box’.

Now, if I select from one list, the other one automatically updates with the corresponding item. This is exactly what I wanted except that previously I had one as a Dropdown list and the other as a text box. I don’t know why I didn’t get there sooner, but it is all a learning curve for me.

I will now inspect the Blazor code to see what was done there and hopefully it will make sense!

Thanks for your help...

1 Like