title: How can I resolve System.InvalidOperationException when I use databind on my dropdownlist in c#
body: <p>I have an issue I need to refresh an <code>asp:dropdownlist</code> but when I do <code>DDList.DataBind()</code> I have this error</p>
  <blockquote>
  <p>System.InvalidOperationException: Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control</p>
  </blockquote>
  <p><strong>.aspx file</strong></p>
  <pre><code>&lt;asp:GridView ID=&quot;GV_LD&quot; runat=&quot;server&quot; AutoGenerateEditButton=&quot;true&quot; AutoGenerateColumns=&quot;False&quot; DataSourceID=&quot;DS_LD&quot; GridLines=&quot;None&quot; DataKeyNames=&quot;ILD&quot; OnDataBound=&quot;GV_LD_DataBound&quot; OnRowDeleted=&quot;GV_LD_RowDeleted&quot;&gt;
      &lt;Columns&gt;
          &lt;asp:BoundField DataField=&quot;AbonnementAchat&quot; HeaderText=&quot;Test&quot; SortExpression=&quot;Qty&quot; DataFormatString=&quot;{0:c}&quot; /&gt;
          &lt;asp:ButtonField ButtonType=&quot;Link&quot; Text=&quot;delete&quot; CommandName=&quot;delete&quot; /&gt;
      &lt;/Columns&gt;
  
  &lt;/asp:GridView&gt;
  
  &lt;asp:FormView ID=&quot;FV_DLD&quot; runat=&quot;server&quot; DataKeyNames=&quot;ILD&quot; DataSourceID=&quot;DS_LD&quot; DefaultMode=&quot;Insert&quot;&gt;   
      &lt;asp:DropDownList ID=&quot;DDList&quot; runat=&quot;server&quot; DataSourceID=&quot;DS_TP&quot; DataTextField=&quot;ic&quot; DataValueField=&quot;icp&quot; SelectedValue='&lt;%# Bind(&quot;icp&quot;) %&gt;' OnDataBound=&quot;DDList_DataBound&quot;&gt;&lt;/asp:DropDownList&gt;
  &lt;/asp:FormView&gt;
  </code></pre>
  <p><strong>.aspx.cs file</strong></p>
  <pre><code>protected void GV_LD_RowDeleted(object sender, GridViewDeletedEventArgs e)
  {
      DropDownList DDList= (DropDownList)FV_DLD.FindControl(&quot;DDList&quot;);
      DDList.DataBind();
  }
  </code></pre>
  <p>So when I click on delete I have the error. Does someone have any idea how to resolve the error?</p>