title: aspxcombobox displaying valuefield instead of textfield
body: <p>I have a aspxgridview that handles batch edit mode.
  The scenario is when I change the <em>Product Id</em> column value, the combobox of the <em>Version Id</em> column is repopulated with versions corresponding to the product. Everything is working fine. Product is populated correctly as well as version but on its default value its showing valuefield instead of textfield and when I try to repopulate again the product so that the version will cascade its seems okay. Just with the default value that showing valuefield instead of textfield. Any help would be much appreciated. Thank you. Please see below for my codes.</p>
  
  <p><strong>JavaScript</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      var curentEditingIndex;
      var lastCountry = null;
      var isCustomCascadingCallback = false;
      function CountriesCombo_SelectedIndexChanged(s, e) {
          lastCountry = s.GetValue();
          isCustomCascadingCallback = true;
          RefreshData(lastCountry);
      }
      function CitiesCombo_EndCallback(s, e) {
          if (isCustomCascadingCallback) {
              if (s.GetItemCount() &gt; 0)
                  sampleGrid2.batchEditApi.SetCellValue(curentEditingIndex, "chndtl_verid", s.GetItem(0).value);
              isCustomCascadingCallback = false;
          }
      }
  
      function OnBatchEditStartEditing(s, e) {
          curentEditingIndex = e.visibleIndex;
          var currentCountry = sampleGrid2.batchEditApi.GetCellValue(curentEditingIndex, "chndtl_prodid");
          if (currentCountry != lastCountry &amp;&amp; e.focusedColumn.fieldName == "chndtl_verid" &amp;&amp; currentCountry != null) {
              lastCountry = currentCountry;
              RefreshData(currentCountry);
          }
      }
  
      function RefreshData(countryValue) {
          hf.Set("CurrentCountry", countryValue);
          version_editor.PerformCallback();
      }
  
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>SqlDataSource</strong></p>
  
  <pre><code>&lt;asp:SqlDataSource ID="Product" runat="server" ConnectionString="&lt;%$ ConnectionStrings:DDS %&gt;"         
          SelectCommand="SELECT [p_pcode], [p_pname] FROM [product] WHERE ([p_stat] = @p_stat)  ORDER BY [p_pname]"&gt;
               &lt;SelectParameters&gt;
                   &lt;asp:Parameter DefaultValue="A" Name="p_stat" Type="String" /&gt;
                    &lt;asp:SessionParameter DefaultValue="" Name="p_advcde" SessionField="advcde" 
                       Type="String" /&gt;
               &lt;/SelectParameters&gt;
          &lt;/asp:SqlDataSource&gt;
  
          &lt;asp:SqlDataSource ID="Version" runat="server" ConnectionString="&lt;%$ ConnectionStrings:DDS %&gt;"         
          SelectCommand="SELECT [v_matid], [v_version] FROM [version] WHERE (v_vpcode = @v_vpcode) ORDER BY [v_version]"&gt;
               &lt;SelectParameters&gt;
                   &lt;asp:Parameter DefaultValue="" Name="v_vpcode" Type="String" /&gt;
                    &lt;/SelectParameters&gt;
          &lt;/asp:SqlDataSource&gt;
  </code></pre>
  
  <p><strong>Front-end</strong></p>
  
  <pre><code>&lt;dx:ASPxGridView ID="ASPxGridView2" ClientInstanceName="sampleGrid2" runat="server"
          AutoGenerateColumns="False" DataSourceID="fordtl" Theme="Material"  KeyFieldName = "chndtl_id"
          Font-Size="11px" CssClass="ChangeEdit" OnCellEditorInitialize="sampleGrid2_CellEditorInitialize"&gt;
      &lt;SettingsEditing Mode="Batch"&gt;&lt;/SettingsEditing&gt;
  
      &lt;dx:GridViewDataComboBoxColumn FieldName="chndtl_prodid"&gt;
          &lt;PropertiesComboBox EnableCallbackMode="true" CallbackPageSize="30"  DataSourceID="Product" ValueField="p_pcode" TextField="p_pname" ValueType="System.Int32"&gt;
          &lt;ClientSideEvents SelectedIndexChanged="CountriesCombo_SelectedIndexChanged" /&gt;
          &lt;/PropertiesComboBox&gt;
      &lt;/dx:GridViewDataComboBoxColumn&gt;
  
      &lt;dx:GridViewDataTextColumn FieldName="chndtl_prod" visible="false"
          ShowInCustomizationForm="True" VisibleIndex="4"&gt;
          &lt;SettingsHeaderFilter&gt;
          &lt;DateRangePickerSettings EditFormatString="" /&gt;
          &lt;/SettingsHeaderFilter&gt;
      &lt;/dx:GridViewDataTextColumn&gt;
  
      &lt;dx:GridViewDataTextColumn FieldName="chndtl_version" visible="true"
          ShowInCustomizationForm="True" VisibleIndex="5" &gt;
      &lt;/dx:GridViewDataTextColumn&gt;
  
      &lt;dx:GridViewDataComboBoxColumn FieldName="chndtl_verid" ShowInCustomizationForm="True" VisibleIndex="6" &gt;
          &lt;PropertiesComboBox EnableCallbackMode="true" OnItemRequestedByValue="OnItemRequestedByValue" 
          OnItemsRequestedByFilterCondition="OnItemsRequestedByFilterCondition"   CallbackPageSize="30" 
          TextField = "v_version" ValueField = "v_matid" ValueType ="System.Int32"&gt;
          &lt;/PropertiesComboBox&gt;
      &lt;/dx:GridViewDataComboBoxColumn&gt;
  
      &lt;/dx:ASPxGridView&gt;
  </code></pre>
  
  <p><strong>Backend</strong></p>
  
  <pre><code> Protected Sub sampleGrid2_CellEditorInitialize(ByVal sender As Object, ByVal e As ASPxGridViewEditorEventArgs)
          If e.Column.FieldName = "chndtl_prodid" Then
              e.Editor.ClientInstanceName = "product_editor"
              Dim cmb_prod As ASPxComboBox = CType(e.Editor, ASPxComboBox) 
              cmb_prod.DataSourceID = "Product"
          cmb_prod.ValueField = "p_pcode"
          cmb_prod.TextField = "p_pname"
          cmb_prod.ClientInstanceName = "product_editor"
          cmb_prod.ValueType = GetType(Integer)
          cmb_prod.DataBindItems()
          End If
          If e.Column.FieldName &lt;&gt; "chndtl_verid" Then
              Return
          End If
          Dim editor = CType(e.Editor, ASPxComboBox)
          editor.ClientInstanceName = "version_editor"
          editor.TextField = "v_version"
          editor.ValueField = "v_matid"
          editor.ValueType = GetType(String)
          editor.DataBindItems()
          editor.ClientSideEvents.EndCallback = "CitiesCombo_EndCallback"
  
      End Sub
      Protected Sub OnItemsRequestedByFilterCondition(ByVal source As Object, ByVal e As ListEditItemsRequestedByFilterConditionEventArgs)
          Dim comboBox As ASPxComboBox = DirectCast(source, ASPxComboBox)
          Dim country As Integer = Me.GetCurrentCountry()
          Version.SelectParameters.Clear()
          Version.SelectParameters.Add("filter", TypeCode.String, String.Format("%{0}%", e.Filter))
          Version.SelectParameters.Add("startIndex", TypeCode.Int32, (e.BeginIndex + 1).ToString())
          Version.SelectParameters.Add("endIndex", TypeCode.Int32, (e.EndIndex + 1).ToString())
          If country &lt;&gt; -1 Then
              Version.SelectParameters.Add("v_vpcode", TypeCode.Int32, country.ToString())
              Version.SelectCommand = "SELECT [v_matid], [v_version] FROM (select [v_matid], [v_version], row_number() over (order by t.[v_matid]) as [rn] from [version] as t where ([v_version] LIKE @filter And [v_vpcode] = @v_vpcode)) as st where st.[rn] between @startIndex and @endIndex"
          Else
              Version.SelectCommand = "SELECT [v_matid], [v_version] FROM (select [v_matid], [v_version], row_number() over (order by t.[v_matid]) as [rn] from [version] as t where ([v_version] LIKE @filter)) as st where st.[rn] between @startIndex and @endIndex"
  
          End If
          comboBox.DataSource = Version
          comboBox.ValueField = "v_matid"
          comboBox.TextField = "v_version"
          comboBox.ValueType = GetType(String)
          comboBox.DataBindItems()
  
      End Sub
  
      Protected Sub OnItemRequestedByValue(ByVal source As Object, ByVal e As ListEditItemRequestedByValueEventArgs)
          If e.Value Is Nothing Then
              Return
          End If
          Dim comboBox As ASPxComboBox = DirectCast(source, ASPxComboBox)
          Version.SelectParameters.Clear()
          Version.SelectCommand = "SELECT [v_matid], [v_version] FROM [version] WHERE (v_vpcode = @v_vpcode) ORDER BY [v_version]"
          Version.SelectParameters.Add("v_vpcode", TypeCode.String, e.Value.ToString())
          Version.DataBind()
          comboBox.DataSource = Version
          comboBox.ValueType = GetType(String)
          comboBox.ValueField = "v_matid"
          comboBox.TextField = "v_version"
          comboBox.DataBind()
      End Sub
  
      Private Function GetCurrentCountry() As Integer
          'INSTANT VB NOTE: The variable id was renamed since Visual Basic does not handle local variables named the same as class members well:
          Dim id_Renamed As Object = Nothing
          If hf.TryGet("CurrentCountry", id_Renamed) Then
              Return Convert.ToInt32(id_Renamed)
          End If
  
          Return -1
      End Function
  </code></pre>