Showing data value in label

Good afternoon,

I have a simple question, but can't seem to figure this out. I want to bind a single data value from my database into a label component, so that the value is shown on the screen while loading the page. Preferably in realtime as well.

I've seen a lot of CRUD options but this always involves a whole table full of data. How can I filter one specific value?

Looking forward to hearing from you!

1 Like

Hi @ChrisI,

Invoke Data Source method can return both collection or single item. For example getOrders() will return IEnumerable<Order> and getOrderById() will return Order. You can get single item from collection of items using for example FirstOrDefault(). Additionally you can appy $filter parameter for getOrders() to limit the records returned as collection. Once you have the item you want you can access any property.

1 Like

Hello @enchev,

Thanks for your response. I've tried to do this but unfortunately it isn't working. See my pictures below how I did this:

image

When I run the application, no value is showing on the screen. Am I doing something wrong?

@enchev So I forgot to add the " " in the query, this fixed everything. Thanks for the help!

Hello @enchev,

It's working properly now. However, I want to update the value when the value in the database changes. Can I implement an update expression within Radzen (if yes, how do I do that?) or do I need to make a custom method and implement this manually?

Looking forward to hearing from you!

Chris

Hi @ChrisI,

The only way to update the value is to invoke again the method that retrieves the data from your database.

Hi @enchev,

Thanks for your reply. I have one question remaining. What method do I need to use when I want to write a single value to a database? I want to change a value within the database when pressing a button. I've made custom code for this but I'm sure you can also achieve this within expressions.

Thanks for the awesome help!

Hi @ChrisI,

To update a database field with new value you need to execute updateXXX method of the service. Check how Edit page executes this method of form Submit event.