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

work on SQL Server 2000. want to Automated Email Notifications using SQL Server Job
At work our end-users are on Windows XP and using Outlook Express. Whenever a
i am trying to load images from the northwind database (categories table, images that
Work got in the way of learning Objective C but i'm back at it
I'm work on project in c# ,and I want to generate data from my
work on asp.net vs05.i want to set mouse event on gridview Then based on
work on asp.net vs05. i know how to show popup ,in my below syntax
work on Sql server 2000. i want to get the current server date and
I'm using VS2008 C# Express and the Northwind database on a Windows Form application.
I am currently playing with the Northwind Sample database that ships with SQL Server.

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.