I'm attempting to hook up a RadzenGrid to a Timer so that I can refresh the page every 5 seconds.
This is the RadzenGrid properties:
RadzenGrid @ref="grid0" AllowFiltering="false" AllowPaging="false" AllowSorting="false" Data="@getVDonorTrackersResult" TItem="DonorTracker.Models.Sqlcluster.VDonorTracker"
And this is the code I have so far:
@code {
private static System.Timers.Timer aTimer;
RadzenGrid gridDT;
protected override void OnInitialized()
{
base.OnInitialized();
// Create a timer with a two second interval.
aTimer = new System.Timers.Timer(5000);
// Hook up the Elapsed event for the timer.
aTimer.Elapsed += OnTimedEvent;
aTimer.AutoReset = true;
aTimer.Enabled = true;
}
private static void OnTimedEvent(Object source, ElapsedEventArgs e)
{
Console.WriteLine("The Elapsed event was raised at {0:HH:mm:ss.fff}", e.SignalTime);
InvokeAsync(gridDT.Reload());
}
}
The Timer is set up properly, but I'm getting an error with the grid itself:
error CS0120: An object reference is required for the non-static field, method, or property 'ViewDonorTracker.gridDT'
I appreciate any insight.
Bill D.