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 942617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:18:08+00:00 2026-05-15T22:18:08+00:00

I work on northwind database. In my AspxGridview I want to show comboBox .

  • 0

I work on northwind database. In my AspxGridview I want to show comboBox. I fill grid on back end C# I also want my combo will fill back end.

 <dxwgv:ASPxGridView ID="ASPxGridView1" runat="server" 
            AutoGenerateColumns="False" KeyFieldName="CategoryID" 
            oncelleditorinitialize="ASPxGridView1_CellEditorInitialize">
            <Columns>
                <dxwgv:GridViewCommandColumn VisibleIndex="0" Width="80px">
                    <EditButton Visible="True">
                    </EditButton>
                    <NewButton Visible="True">
                    </NewButton>
                    <DeleteButton Visible="True">
                    </DeleteButton>
                </dxwgv:GridViewCommandColumn>
                <dxwgv:GridViewDataTextColumn Caption="CategoryID" FieldName="CategoryID" 
                    VisibleIndex="1">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataComboBoxColumn Caption="CategoryName" 
                    FieldName="CategoryName" VisibleIndex="2">
                    <PropertiesComboBox TextField="Value" ValueField="key" ValueType="System.Int32">
                        <ClientSideEvents SelectedIndexChanged="function(s, e) { OnBankChanged(s); }" />
                    </PropertiesComboBox>
                </dxwgv:GridViewDataComboBoxColumn>
                <dxwgv:GridViewDataTextColumn Caption="Description" FieldName="Description" 
                    VisibleIndex="3">
                </dxwgv:GridViewDataTextColumn>
            </Columns>
        </dxwgv:ASPxGridView>

To fill grid i use the bellow C# syntax.

  DataClasses1DataContext db = new DataClasses1DataContext();
            var r = from p in db.Categories
                    select p;
            ASPxGridView1.DataSource = r;
            ASPxGridView1.DataBind();

To fill gridview cell of combo i use Bellow C# syntax

 protected void ASPxGridView1_CellEditorInitialize(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewEditorEventArgs e)
        {
            if (!ASPxGridView1.IsEditing || e.Column.FieldName != "CategoryID") return;
            ASPxComboBox combo = e.Editor as ASPxComboBox;

            if (!(e.KeyValue == DBNull.Value || e.KeyValue == null)) //return;
            {
                object val = ASPxGridView1.GetRowValuesByKeyValue(e.KeyValue, "CategoryID");
                if (val == DBNull.Value) return;
                Int32 CategoryID = (Int32)val;
                FillCityCombo(combo, CategoryID);
            }

            combo.Callback += new CallbackEventHandlerBase(cmbBranch_OnCallback);

        }

        private void cmbBranch_OnCallback(object source, CallbackEventArgsBase e)
        {
            FillCityCombo(source as ASPxComboBox, Convert.ToInt16(e.Parameter));
        }

        protected void FillCityCombo(ASPxComboBox cmb, Int32 CategoryID)
        {
            //cmb.Items.Clear();
            //cmb.DataSourceID = "";
            DataClasses1DataContext db = new DataClasses1DataContext();
            var r = from p in db.Categories
                    select new { p.CategoryID,p.CategoryName};
            cmb.DataSource = r;
            cmb.DataBind();
        }

When I run the code AspxGridview fill well but when I click on Edit or New Command on left side of my grid shows me error message below:

**Object reference not set to an instance of an object.**
  1. What’s the problem?
  2. How to solve this problem?
  3. How to bind cell combo on aspx gridview?
  • 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-15T22:18:09+00:00Added an answer on May 15, 2026 at 10:18 pm

    This is the cause of this issue. You are checking for the “CategoryID” field name. But the ComboBox column is created for the “CategoryName” field:

    if (!ASPxGridView1.IsEditing || e.Column.FieldName != "CategoryID") return;
    ASPxComboBox combo = e.Editor as ASPxComboBox;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I work in VBA, and want to parse a string eg <PointN xsi:type='typens:PointN' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
i am trying to load images from the northwind database (categories table, images that
I'm using VS2008 C# Express and the Northwind database on a Windows Form application.
I'm work on project in c# ,and I want to generate data from my
I want the messagebox to only show if the number is equal to 0.
I work with Maven2 . I want to know is there a way to
Once work items in a particular workflow reach a tested/resolved end state, I don't
At work we are currently still using JUnit 3 to run our tests. We
At work we are being asked to create XML files to pass data to
I work with C# at work but dislike how with webforms it spews out

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.