Show Button Based on Whether Data is in a Field

I'm trying to display a button in a grid based on whether data is present in a particular column. I've tried a couple variations, but don't think I have the correct syntax. So far I've attempted ${result.Count}>1 and ${result.Contains("AValue")}, and set the visibility property to one of these booleans. Any tips on setting something like this up?

Thanks,

Bill

The context in the column Template is the data item. Check this demo:
https://blazor.radzen.com/datagrid-conditional-template

You could do it like this:

  1. Add the Button component
  2. Set its Visible property to an expression such as ${data.PropertyName.Contans("AValue")}

Related resources from the documentation:

  1. Expressions and the data implicit property.
  2. Templates
  3. The Visible property

Thanks guys, I've read through all that documentation, and I think my code is OK (I'm trying to use ${data.Enroute.Contains("Enroute")} ), however I'm getting the following error when trying to view my page:

dotnet: warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]
Unhandled exception rendering component: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at DonorTracker.Pages.ViewDonorTracker.<>c__DisplayClass0_0.b__4(RenderTreeBuilder __builder4)
at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment)
at Radzen.Blazor.RadzenGrid1.<>c__DisplayClass0_3.<BuildRenderTree>b__28(RenderTreeBuilder __builder2) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at Radzen.Blazor.RadzenGridRow.<BuildRenderTree>b__0_0(RenderTreeBuilder __builder2) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at Microsoft.AspNetCore.Components.CascadingValue1.Render(RenderTreeBuilder builder)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()

dotnet: fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
Unhandled exception in circuit 'veJ5N8ZB3ZVQBRBuwqRrN97H60viZc3x9ntIU-r5I4Q'.
System.NullReferenceException: Object reference not set to an instance of an object.
at DonorTracker.Pages.ViewDonorTracker.<>c__DisplayClass0_0.b__4(RenderTreeBuilder __builder4)
at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment)
at Radzen.Blazor.RadzenGrid1.<>c__DisplayClass0_3.<BuildRenderTree>b__28(RenderTreeBuilder __builder2) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at Radzen.Blazor.RadzenGridRow.<BuildRenderTree>b__0_0(RenderTreeBuilder __builder2) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at Microsoft.AspNetCore.Components.CascadingValue1.Render(RenderTreeBuilder builder)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()

Not sure what the cause could be.

Also the above error happens whenever I'm trying to access any method off ${data.field.AnyFunction()} like ${data.Enroute.ToUpper()} or ${data.Enroute.ToLower()}

This could happen if the Enroute property is null for some reason. Could this be the case? You can use the ?. operator which will make the method not execute if the property is null:

${data.Enroute?.ToUpper()}

I think that is exactly what is happening. Some of the values are NULL in that column. I do run into another issue though:

dotnet: Pages\TestViewDonorTracker.razor(41,84): error CS1503: Argument 1: cannot convert from 'bool?' to 'bool'

This would indeed happen because the Visible property is bool and the ?. expression evaluates to bool? (Nullable). Try ${data.PropertyName?.Contains("AValue") == true}

Thanks! That works great!