title: DevExpress dxDataGrid for Blazor - "There was an unhandled exception on the current circuit" error
body: <p>I am using <strong>dxDataGrid</strong> for <em>Blazor</em> to build a project,but there are some errors when I try to add a new row or edit the current row.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Error: There was an unhandled exception on the current circuit, so this circuit will be terminated. For more details turn on detailed exceptions in 'CircuitOptions.DetailedErrors'. 
  [2019-09-26T11:13:47.533Z] Information: Connection disconnected.</code></pre>
  </div>
  </div>
  </p>
  
  <p>And I got this error:
  <a href="https://i.stack.imgur.com/Wxn1W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wxn1W.png" alt="enter image description here"></a></p>
  
  <p>My first thought that <strong>SignalR</strong> was disconnected.but I don't know why or how to configure?</p>
  
  <p>Does anyone have any idea? Can you please tell me?</p>
  
  <p>I get some new details of the error on the basis of Mikhail's suggestions . I get the first error When I first tried,and then I get the second error when I tried the second time. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Error: System.NullReferenceException: Object reference not set to an instance of an object.
  Uncaught (in promise) Error: Cannot send data if the connection is not in the 'Connected' State.</code></pre>
  </div>
  </div>
  </p>
  
  <p>It looks like something's wrong with my code.but I still don't have any ideas about the errors, so I paste my code snippet below.</p>
  
  <pre><code>&lt;DxDataGrid Id="aa" Data="@activityDtos" @ref="@grid"
              ShowFilterRow="false"
              RowRemoving="@((dataItem) =&gt; OnRowRemoving(dataItem))"
              RowUpdating="@((updatingDataItem, newValues) =&gt; OnRowUpdating(updatingDataItem, newValues))"
              RowInserting="@((newValues) =&gt; OnRowInserting(newValues))"&gt;
  
      &lt;DxDataGridCommandColumn Width="150px" Context="编辑"&gt;&lt;/DxDataGridCommandColumn&gt;
  
      &lt;DxDataGridColumn Field="@nameof(ActivityDto.ActivityCode)" Caption="Activity Code"&gt;&lt;/DxDataGridColumn&gt;
  
      &lt;DxDataGridColumn Field="@nameof(ActivityDto.ActText1)" Caption="Text1"&gt;&lt;/DxDataGridColumn&gt;
  
      &lt;DxDataGridColumn Field="@nameof(ActivityDto.ActText2)" Caption="Text2"&gt;&lt;/DxDataGridColumn&gt;
  
      &lt;DxDataGridColumn Field="@nameof(ActivityDto.ActivityStatusID)" Caption="Status"&gt;
          &lt;DisplayTemplate&gt;
              @{
                  var feild = (context as ActivityDto).ActivityStatusID == "A" ? "Active" : "Inactive";
                  &lt;label&gt;&lt;span&gt;@feild&lt;/span&gt;&lt;/label&gt;
              }
          &lt;/DisplayTemplate&gt;
          &lt;EditTemplate&gt;
              &lt;DxComboBox Data="@(new List&lt;string&gt;() { "Active", "Inactive" })"
                          SelectedItem="@(((bool)((CellEditContext)context).CellValue) ? "Active" : "Inactive" )"
                          SelectedItemChanged="@(newCellValue =&gt; ((CellEditContext)context).OnChanged(newCellValue == "Active"))"&gt;
              &lt;/DxComboBox&gt;
          &lt;/EditTemplate&gt;
      &lt;/DxDataGridColumn&gt;
  
      &lt;DxDataGridColumn Caption="Default"&gt;
          &lt;DisplayTemplate&gt;
              @{
                  var id = Guid.NewGuid().ToString();
                  var isDefault = (context as ActivityDto).IsDefault;
                  &lt;input id="@id" type="checkbox" checked="@isDefault" /&gt;
              }
          &lt;/DisplayTemplate&gt;
      &lt;/DxDataGridColumn&gt;
  
  &lt;/DxDataGrid&gt;
  </code></pre>
  
  <p>and there is the code of C#.</p>
  
  <pre><code>    string ActivityCode, Text1Value, Text2Value, Status,Status1;
  IQueryable&lt;ActivityDto&gt; activityDtos;
  
  ActivityFormDataItem editFormData = new ActivityFormDataItem()
  {
      Status = "All",
      CompanyId = 37
  };
  
  protected override async Task OnInitializedAsync()
  {
      activityDtos = await ActivitiesService.ActivitiesForAsync(editFormData);
      SearchDtos = await ActivitiesService.SearchDtosForAsync();
  }
  
  async void OnRowRemoving(ActivityDto dataItem)
  {
      ActivitiesService.Remove(dataItem);
      await InvokeAsync(StateHasChanged);
  }
  
  async void OnRowUpdating(ActivityDto dataItem, Dictionary&lt;string, object&gt; newValue)
  {
      ActivitiesService.Update(dataItem, newValue);
      await InvokeAsync(StateHasChanged);
  }
  async void OnRowInserting(Dictionary&lt;string, object&gt; newValue)
  {
      ActivitiesService.Insert(newValue);
      await InvokeAsync(StateHasChanged);
  }
  
  protected async Task OnAfterRenderAsync()
  {
      editFormData = new ActivityFormDataItem()
      {
          Status = Status1,
          ActivityCode=ActivityCode,
          CompanyId = 37,
          Text1Value=Text1Value,
          Text2Value=Text2Value
      };
      activityDtos = await ActivitiesService.ActivitiesForAsync(editFormData);
      if (!string.IsNullOrEmpty(editFormData.Status))
          editFormData.Status = editFormData.Status == "A" ? "Active" : "Inactive";
      else
          editFormData.Status = "All";
      await InvokeAsync(StateHasChanged);
  }
  </code></pre>