title: Exception: 'System.OutOfMemoryException' was thrown when there is 20,000+ data need to be bind in RadComboBox inside RadGrid
body: <p>I have a <strong>RadGrid</strong> and a <strong>RadComboBox outside</strong> of RadGrid (say <strong>comboOutside</strong>), inside a Web Form.<br/>
  Inside RadGrid, there is 1 more RadComboBox (say <strong>comboRadGrid</strong>). On selection of items from comboOutside, comboRadGrid is bind <strong>i.e.,</strong> If item 'Company' is selected from comboOutside, then all the company names will be bind in comboRadGrid; and then user select specific company from comboRadGrid and records are added in RadGrid.<br/></p>
  
  <p>For all items, functionality is working fine but I am facing issue in binding of a specific comboOutside item.
  i.e., When I choose a specific item from comboOutside, say I have 100 items inside comboOutside, and when I select 35th items from it, then comboRadGrid always throw this error while binding records for 35th item (since 35th item has 2000+ records to bind in comboRadGrid)<br/>
  Error is below:
  <a href="https://i.stack.imgur.com/gUhb7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gUhb7.png" alt="enter image description here"></a></p>
  
  <p>Funcitonality is working fine for all the items except 1 specific item of RadComboBox. I don't understand why. Due to this I am unable to add records in RadGrid<br/>
  Below is my code-
  <strong>C# code</strong></p>
  
  <pre><code>public DataTable GetAccCode(string CompanyCode)
      {
          SqlConnection con = new SqlConnection(strcon);
          SqlCommand cmd = new SqlCommand("[Invoice].[usp_tbl_AccountCode_DL_Test]", con);
          cmd.CommandType = CommandType.StoredProcedure;
          cmd.Parameters.AddWithValue("@CompanyCode", CompanyCode);
          SqlDataAdapter da = new SqlDataAdapter(cmd);
          DataTable dt = new DataTable();
          try
          {
              con.Open();
              da.Fill(dt);
              con.Close();
          }
          catch (Exception ex)
          {
          }
          return dt;
      }
  protected void RGGSTAcCode_ItemDataBound(object sender, GridItemEventArgs e)
      {
          if (e.Item is GridEditableItem &amp;&amp; e.Item.IsInEditMode)
          {
              //bind dropdwon while "Add" 
              string CompanyCode = ddlCompany.SelectedValue.ToString();
              GridEditableItem item = (GridEditableItem)e.Item;
  
              //code to bind inside RadComboBox list   
              RadComboBox rcb = (RadComboBox)item.FindControl("ddlAccountCode");
              rcb.DataSource = GetAccCode(CompanyCode);
              rcb.DataTextField = "AccountDescription";
              rcb.DataValueField = "AccountCodeID";
              rcb.DataBind();
              rcb.Items.Insert(0, new RadComboBoxItem("- Select -", string.Empty));
  
              Session["AccCode"] = rcb.SelectedValue.ToString();
              string a = rcb.SelectedValue.ToString();
  
              //Select particular dropdown value while "Edit"
              Label lblAcCode2 = item.FindControl("lblAcCode2") as Label;
              if (!string.IsNullOrEmpty(lblAcCode2.Text))
              {
                  rcb.SelectedValue = lblAcCode2.Text;
                  rcb.SelectedItem.Text = lblAcCode2.Text;
              }
          }
      }
       //code to bind outside RadComboBox list
          protected void BindComapnyDL()
          {
              SqlConnection con = new SqlConnection(strcon);
              SqlCommand cmd = new SqlCommand("General.usp_tbl_BuyerCode_Query", con);
              cmd.CommandType = CommandType.StoredProcedure;
              SqlDataAdapter da = new SqlDataAdapter(cmd);
              DataTable dt = new DataTable();
              try
              {
                  con.Open();
                  da.Fill(dt);
                  con.Close();
              }
              catch (Exception ex)
              {
              }
  
              ddlCompany.DataTextField = "Title";
              ddlCompany.DataValueField = "Code";
              ddlCompany.DataSource = dt;
              ddlCompany.DataBind();
  
              Session["Comp"] = ddlCompany.SelectedValue.ToString();
              string a = ddlCompany.SelectedValue.ToString();      
          }
  
          //RadComboBox select index changed event
          protected void ddlCompany_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
          {
              if (ddlCompany.SelectedValue == null || ddlCompany.SelectedValue == "")
              {
                  GridCommandItem cmditem = (GridCommandItem)RGGSTAcCode.MasterTableView.GetItems(GridItemType.CommandItem)[0];
                  System.Web.UI.WebControls.Button ctrl = (System.Web.UI.WebControls.Button)cmditem.FindControl("AddNewRecordButton");
                  ctrl.Enabled = false;
  
                  System.Web.UI.WebControls.LinkButton btn = (System.Web.UI.WebControls.LinkButton)cmditem.FindControl("InitInsertButton");
                  btn.Enabled = false;
  
                  string content = "Please select company first";
                  ScriptManager.RegisterStartupScript(this, typeof(string), "Successful", "alert('" + content + "');", true);
              }
              else
              {
                  RGGSTAcCode.Rebind();
              }
          }
  </code></pre>
  
  <p><strong>HTML code</strong></p>
  
  <pre><code>&lt;telerik:RadComboBox ID="ddlCompany" runat="server" Height="200" Width="240"
            DropDownWidth="310" EmptyMessage="- Select Product -" HighlightTemplatedItems="true" CausesValidation="false"
            Filter="Contains" AppendDataBoundItems="true" AllowCustomText="true" AutoPostBack="true"
            DataTextField="Title" DataValueField="Code" OnSelectedIndexChanged="ddlCompany_SelectedIndexChanged"&gt;
          &lt;/telerik:RadComboBox&gt;
  
  &lt;telerik:RadGrid ID="RGGSTAcCode" runat="server"
                     ShowFooter="True" GroupingEnabled="False" ShowStatusBar="true" EmptyDataText="No record available." 
                     AllowAutomaticInserts="False" AllowAutomaticUpdates="False" AllowAutomaticDeletes="true" 
                     OnNeedDataSource="RGGSTAcCode_NeedDataSource" OnItemDataBound="RGGSTAcCode_ItemDataBound" 
                     OnInsertCommand="RGGSTAcCode_InsertCommand" OnDeleteCommand="RGGSTAcCode_DeleteCommand" 
                     OnUpdateCommand="RGGSTAcCode_UpdateCommand" OnItemCommand="RGGSTAcCode_ItemCommand"&gt;
                    &lt;mastertableview ShowHeadersWhenNoRecords="true" autogeneratecolumns="false" datakeynames="AccountCodeID" InsertItemDisplay="Top"
                      insertitempageindexaction="ShowItemOnCurrentPage" ShowFooter="True" CommandItemDisplay="Top" ClientIDMode="Static"&gt;                                   
                           &lt;Columns&gt; 
                               &lt;telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"&gt;&lt;/telerik:GridEditCommandColumn&gt; 
  
                               &lt;telerik:GridTemplateColumn UniqueName="AccountCode" HeaderText="Account Code"&gt;
                                  &lt;ItemTemplate&gt;
                                    &lt;asp:Label ID="lblAcCode" runat="server" Text='&lt;%# Eval("AccountCode")%&gt;'&gt;&lt;/asp:Label&gt;
                                  &lt;/ItemTemplate&gt;
                                  &lt;EditItemTemplate&gt;
                                     &lt;asp:Label ID="lblAcCode2" runat="server" Text='&lt;%# Eval("AccountCode") + " - " + Eval("AccountDescription")%&gt;' Visible="false"&gt;&lt;/asp:Label&gt;
  
                                     &lt;telerik:RadComboBox ID="ddlAccountCode" runat="server" Height="200" Width="240"
                                         DropDownWidth="310" HighlightTemplatedItems="true" CausesValidation="true"
                                         Filter="Contains" AppendDataBoundItems="true" DataTextField="AccountDescription" DataValueField="AccountCodeID"&gt;
                                     &lt;/telerik:RadComboBox&gt;
                                  &lt;/EditItemTemplate&gt;
                               &lt;/telerik:GridTemplateColumn&gt;
  
                               &lt;telerik:GridBoundColumn DataField="AccountDescription" HeaderText="Description" UniqueName="AccountDescription" SortExpression="AccountDescription" InsertVisiblityMode="AlwaysHidden" ReadOnly="true" &gt;&lt;/telerik:GridBoundColumn&gt;
                               &lt;telerik:GridBoundColumn aggregate="SUM" DataField="Amount" HeaderText="Amount" FooterAggregateFormatString="Total : {0:###,##0.00}" DataFormatString="{0:n}" FooterStyle-BackColor="#ffc04c" UniqueName="Amount" SortExpression="Amount"&gt;&lt;/telerik:GridBoundColumn&gt;
                               &lt;telerik:GridBoundColumn DataField="Remark" HeaderText="IFCA Remark" UniqueName="Remark" SortExpression="Remark"&gt;
  
                               &lt;/telerik:GridBoundColumn&gt;    
  
                               &lt;telerik:GridButtonColumn ConfirmTextFormatString="Are you sure you want to Delete {0} Account Code?" ConfirmTextFields="AccountCodeID"
                               ConfirmDialogType="RadWindow" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"&gt;&lt;/telerik:GridButtonColumn&gt;                                                                            
                        &lt;/Columns&gt;
                        &lt;EditFormSettings&gt;
                           &lt;EditColumn ButtonType="ImageButton" /&gt;
                        &lt;/EditFormSettings&gt;
                        &lt;CommandItemSettings AddNewRecordText="Add new record" RefreshText="Refresh"&gt;&lt;/CommandItemSettings&gt;
                    &lt;/mastertableview&gt;
                  &lt;/telerik:RadGrid&gt; 
  </code></pre>
  
  <p>Please let me know why this error is coming for a specific item of <code>RadComboBox</code> selection.</p>