diff --git a/components/combobox/refresh-data.md b/components/combobox/refresh-data.md
index d9e9473601..530d13430d 100644
--- a/components/combobox/refresh-data.md
+++ b/components/combobox/refresh-data.md
@@ -24,67 +24,62 @@ In this article:
To refresh the ComboBox data when using [`OnRead`](slug:components/combobox/events#onread), call the `Rebind` method of the TelerikComboBox reference. This will fire the `OnRead` event and execute the business logic in the handler.
````RAZOR
-@* Clicking on the Rebind button will delete the first option from the dropdown and refresh the data *@
-
@using Telerik.DataSource.Extensions
-Rebind
+Remove First Data Item and Rebind
+
+ @bind-Value="@ComboBoxValue"
+ OnRead="@OnComboBoxRead"
+ TItem="ListItem"
+ TValue="int"
+ ValueField="@nameof(ListItem.Id)"
+ TextField="@nameof(ListItem.Text)"
+ Width="200px">
@code{
- public int SelectedValue { get; set; }
- List AllData { get; set; } = new List();
- public TelerikComboBox ComboBoxRef { get; set; }
-
- async Task ReadItems(ComboBoxReadEventArgs args)
- {
- await Task.Delay(1000);
- args.Data = AllData.ToDataSourceResult(args.Request).Data;
- }
+ public TelerikComboBox? ComboBoxRef { get; set; }
+ private List AllData { get; set; } = new();
+ private int ComboBoxValue { get; set; }
- protected override void OnInitialized()
+ private void RebindComboBox()
{
- List products = new List();
- for (int i = 0; i < 200; i++)
+ if (AllData.Count > 1)
{
- products.Add(new Product()
- {
- ProductId = i,
- ProductName = "Product" + i.ToString(),
- SupplierId = i,
- UnitPrice = (decimal)(i * 3.14),
- UnitsInStock = (short)(i * 1),
- });
+ AllData.RemoveAt(0);
}
- AllData = products;
+ ComboBoxValue = AllData.FirstOrDefault()?.Id ?? default;
+
+ ComboBoxRef?.Rebind();
}
- public class Product
+ private async Task OnComboBoxRead(ComboBoxReadEventArgs args)
{
- public int ProductId { get; set; }
- public string ProductName { get; set; }
- public int SupplierId { get; set; }
- public decimal UnitPrice { get; set; }
- public short UnitsInStock { get; set; }
+ var result = await AllData.ToDataSourceResultAsync(args.Request);
+ args.Data = result.Data;
+ args.Total = result.Total;
}
- private void RebindComboBox()
+ protected override void OnInitialized()
{
- if (AllData.Count > 0)
+ for (int i = 1; i <= 5; i++)
{
- AllData.RemoveAt(0);
+ AllData.Add(new ListItem()
+ {
+ Id = i,
+ Text = $"ListItem {i}"
+ });
}
- ComboBoxRef.Rebind();
+ ComboBoxValue = AllData.First().Id;
+ }
+
+ public class ListItem
+ {
+ public int Id { get; set; }
+ public string Text { get; set; } = string.Empty;
}
}
````
@@ -232,4 +227,4 @@ To refresh the ComboBox data when using [`OnRead`](slug:components/combobox/even
* [ObservableCollection](slug:common-features-observable-data)
* [INotifyCollectionChanged Interface](https://docs.microsoft.com/en-us/dotnet/api/system.collections.specialized.inotifycollectionchanged?view=netframework-4.8)
- * [Live Demos](https://demos.telerik.com/blazor-ui)
\ No newline at end of file
+ * [Live Demos](https://demos.telerik.com/blazor-ui)