Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6017331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:06:46+00:00 2026-05-23T03:06:46+00:00

im using the Devexpress ASPxGridView for a project but are having problems to populate

  • 0

im using the Devexpress ASPxGridView for a project but are having problems to populate a custom EditForm with data.

It looks as follows

<Templates>
    <EditForm>
        Company Name:
        <dx:ASPxTextBox ID="CompanyName" runat="server" Value="<% #Bind('CompanyName') %>" />
        Parent:
        <dx:ASPxListBox ID="ParentGuid" runat="server" Value="<% #Bind('ParentGuid') %>" />
    </EditForm>
</Templates>

Normally I’d write something like

protected void ASPxGridView1_StartRowEditing(object sender, DevExpress.Web.Data.ASPxStartRowEditingEventArgs e)
{
    var CompanyList = db.companies.OrderBy(x => 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";
}

But that wont work. Any advice where to start? The documentation doesn’t really cover custom forms that well :/

Thanks!

== UPDATE ==

Tried using the onhtmleditformcreated=”ASPxGridView1_HtmlEditFormCreated” with the method

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";
    }

}

The fact that I use Value=”<% #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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:06:47+00:00Added an answer on May 23, 2026 at 3:06 am

    The answer is…

    To populate a ASPxComboBox called CompanyList

    protected void ASPxGridView1_HtmlEditFormCreated(object sender, ASPxGridViewEditFormEventArgs e)
    {
        Control ParentGuidControl = ASPxGridView1.FindEditFormTemplateControl("ParentGuid");
        if (ParentGuidControl != null)
        {
            ASPxComboBox ParentGuid = (ASPxComboBox)ParentGuidControl;
    
            var CompanyList = db.companies.OrderBy(x => x.CompanyName);
            ParentGuid.TextField = "CompanyName";
            ParentGuid.ValueField = "CompanyGuid";
            ParentGuid.DataSource = CompanyList;
            ParentGuid.DataBind();
        }
    }
    

    BUT!

    If you have a custom form like i had

    <Templates>
        <EditForm>
            Company Name:
            <dx:ASPxTextBox ID="CompanyName" runat="server" Value="<% #Bind('CompanyName') %>" />
            Parent:
            <dx:ASPxComboBox ID="ParentGuid" runat="server" Value="<% #Bind('ParentGuid') %>" />
        </EditForm>
    </Templates>
    

    you wont be able to populate it from code-behind, the #bind method is in the way and overwrite any other incoming value. However if you are not planning to populate them from code behind here is a neat trick to fetch the data…

    protected void ASPxGridView1_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        IDictionaryEnumerator enumerator = e.NewValues.GetEnumerator();
    
        string CompanyName = string.Empty;
        Guid ParentGuid = Guid.Empty;
    
        enumerator.Reset();
        while (enumerator.MoveNext())
            if (enumerator.Key.ToString() == "CompanyName")
                CompanyName = enumerator.Value.ToString();
            else if (enumerator.Key.ToString() == "ParentGuid")
                ParentGuid = new Guid(enumerator.Value.ToString());
    
        // Do insert trick here
    
    }
    

    But if you want to fill some of the form values from code-behind ensure there are no #bind methods in the EditForm

    <Templates>
        <EditForm>
            Company Name:
            <dx:ASPxTextBox ID="CompanyName" runat="server" />
            Parent:
            <dx:ASPxComboBox ID="ParentGuid" runat="server" />
        </EditForm>
    </Templates>
    

    Populate as described in the top of this post and fetch the values like this

    protected void ASPxGridView1_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        string CompanyName = string.Empty;
        Guid ParentGuid = Guid.Empty;
    
        // This method is a bit more secure
        Control CompanyNameControl = ASPxGridView1.FindEditFormTemplateControl("CompanyName");
        if (CompanyNameControl != null)
        {
            ASPxTextBox CompanyNameTb = (ASPxTextBox)CompanyNameControl;
            CompanyName = CompanyNameTb.Text.ToString();
        }
    
        // A bit less secure, but lesser code
        ASPxComboBox ParentGuidControl = (ASPxComboBox)ASPxGridView1.FindEditFormTemplateControl("ParentGuid");
        ParentGuid = new Guid(ParentGuidControl.SelectedItem.Value.ToString());
    
        // Do insert...
    
    }
    

    Have fun

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP .net C# project using a EntityDataSource with a DevExpress aspxGridView
I have D2006 and I am using DevExpress QuantumGrid 6 in a project. I
I am using DevExpress OrgChart component that is still maintained but not developed since
Hello I am needing to deploy a project using DevExpress controls to an IIS
I have a project using DevExpress docking components, I create forms in run-time, which
I am using DevExpress in my Winform project, and in my form there are
I am using DevExpress in my winform application, I have a gridview, data entry
I'm using DevExpress XtraReports in a WinForms application, but could equally apply to other
i am using devexpress gridview 9.2. i have 2 gridview having 2 colum -->
I'm using devExpress 11.1 with MVC 3/razor and i'm experiencing problems with putting html

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.