blazor-devexpress-dot-blazor-dot-dxradiogroup-2-78f399f9.md
Specifies the data source field that contains text for Radio Group items.
Namespace : DevExpress.Blazor
Assembly : DevExpress.Blazor.v25.2.dll
NuGet Package : DevExpress.Blazor
[Parameter]
public string TextFieldName { get; set; }
| Type | Description |
|---|---|
| String |
A string value that specifies a data source field’s name.
|
<legend>Select your drink:</legend>
<DxRadioGroup Items="@Drinks"
@bind-Value="@SelectedDrinkId"
ValueFieldName="@nameof(Product.ProductId)"
EnabledFieldName="@nameof(Product.InStock)"
TextFieldName="@nameof(Product.ProductName)">
</DxRadioGroup>
<p>
You have selected:
<strong>@GetDrinkName()</strong>
</p>
@code {
int SelectedDrinkId { get; set; } = 2;
IEnumerable<Product> Products { get; set; }
IEnumerable<Product> drinks;
IEnumerable<Product> Drinks {
get => drinks;
set {
drinks = value;
InvokeAsync(StateHasChanged);
}
}
protected override async Task OnInitializedAsync() {
Products = await NwindDataService.GetProductsAsync();
Drinks = Products.Where(p => p.CategoryId == 1).Take(5).AsEnumerable();
}
string GetDrinkState(Product product) => product.InStock ? $"({product.UnitsInStock} units left)" : "(out of stock)";
string GetDrinkName() => Drinks.First(p => p.ProductId == SelectedDrinkId).ProductName;
}
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
public partial class Product {
public Product() {
OrderDetails = new HashSet<OrderDetail>();
}
public int ProductId { get; set; }
public string ProductName { get; set; }
public int? SupplierId { get; set; }
public int? CategoryId { get; set; }
public string QuantityPerUnit { get; set; }
public decimal? UnitPrice { get; set; }
public short? UnitsInStock { get; set; }
public short? UnitsOnOrder { get; set; }
public short? ReorderLevel { get; set; }
public bool Discontinued { get; set; }
public bool InStock => !Discontinued;
public virtual Category Category { get; set; }
public virtual Supplier Supplier { get; set; }
public virtual ICollection<OrderDetail> OrderDetails { get; set; }
}
See Also
DxRadioGroup<TData, TValue> Class