title: Populate ASPxTextBox and ASPxListBox from Code Behind
body: <p>im using the Devexpress ASPxGridView for a project but are having problems to populate a custom EditForm with data.</p>
  
  <p>It looks as follows</p>
  
  <pre><code>&lt;Templates&gt;
      &lt;EditForm&gt;
          Company Name:
          &lt;dx:ASPxTextBox ID="CompanyName" runat="server" Value="&lt;% #Bind('CompanyName') %&gt;" /&gt;
          Parent:
          &lt;dx:ASPxListBox ID="ParentGuid" runat="server" Value="&lt;% #Bind('ParentGuid') %&gt;" /&gt;
      &lt;/EditForm&gt;
  &lt;/Templates&gt;
  </code></pre>
  
  <p>Normally I'd write something like</p>
  
  <pre><code>protected void ASPxGridView1_StartRowEditing(object sender, DevExpress.Web.Data.ASPxStartRowEditingEventArgs e)
  {
      var CompanyList = db.companies.OrderBy(x =&gt; x.CompanyName).ToList();
      ASPxListBox ParentGuid = (ASPxListBox)ASPxGridView1.FindControl("ParentGuid");
      ParentGuid.DataSource = CompanyList;
      ParentGuid.DataBind();
  
      ASPxTextBox CompanyName = (ASPxTextBox)ASPxGridView1.FindControl("CompanyName");
      CompanyName.Text = "Some company name";
  }
  </code></pre>
  
  <p>But that wont work. Any advice where to start? The documentation doesn't really cover custom forms that well :/</p>
  
  <p>Thanks!</p>
  
  <p><strong>== UPDATE ==</strong></p>
  
  <p>Tried using the onhtmleditformcreated="ASPxGridView1_HtmlEditFormCreated" with the method</p>
  
  <pre><code>protected void ASPxGridView1_HtmlEditFormCreated(object sender, ASPxGridViewEditFormEventArgs e)
  {
      Control CompanyName = ASPxGridView1.FindEditFormTemplateControl("CompanyName");
      if (CompanyName != null)
      {
          ASPxTextBox CompanyNameEdit = CompanyName as ASPxTextBox;
          CompanyName.Text = "Some Co";
      }
  
  }
  </code></pre>
  
  <p>The fact that I use Value="&lt;% #Bind('CompanyName') %>" messes stuff up a bit. If i remove the Bind the boxes gets populated but then I have no way of fetching the data in them. Any way around this?</p>