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

  • Home
  • SEARCH
  • 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 8669311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:26:34+00:00 2026-06-12T18:26:34+00:00

I am getting the above error when i am trying this code. I tried

  • 0

I am getting the above error when i am trying this code. I tried giving just my code but no use. (It was default)

Here is my XML file

The error is in cmbProduct_SelectedIndexChanged event.

        cmbProduct --> combobox
        cmbBrand   --> combobox

Global

        DataSet dsUpdate = new DataSet();

Form_load

        dsUpdate.ReadXml(@"...\..\stock.xml");
        cmbProduct.DataSource = dsUpdate.Tables[0]
            .DefaultView.ToTable(true, "productname");//.DefaultView;
        cmbProduct.DisplayMember = "productname";
        cmbProduct.SelectedIndex = 0;

cmbProduct_SelectedIndexChanged

        cmbBrand.Items.Clear();
        foreach (DataRow Row in dsUpdate.Tables[0].Select("productname='" + cmbProduct.Text + "'"))
        {
            //cmbBrand.SelectedIndex = i;
            cmbBrand.Items.Add(Row["brandname"].ToString());
            //i++;
        } 
        cmbBrand.SelectedIndex = 0; /*ERROR*/  

Please help

Thanks in Advance.

  • 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-06-12T18:26:35+00:00Added an answer on June 12, 2026 at 6:26 pm

    Problem is:

    when you start application, you do not have items in cmbBrand, but cmbProduct fires SelectedIndexChanged.

    Try this:

    remove SelectedIndexChanged event initialization from Form1.Designer.cs. Try to find following line:

    this.cmbProduct.SelectedIndexChanged += new System.EventHandler(this.cmbProduct_SelectedIndexChanged);
    

    After that, when you populate DataSet with data from xml file, initialize SelectedIndexChanged event:

    dsUpdate.ReadXml(@"...\..\stock.xml");
    cmbProduct.DataSource = dsUpdate.Tables[0].DefaultView.ToTable(true, "productname");//.DefaultView;
    cmbProduct.DisplayMember = "productname";
    this.cmbProduct.SelectedIndexChanged += new System.EventHandler(this.cmbProduct_SelectedIndexChanged);
    cmbProduct.SelectedIndex = 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting the above error when trying to delete the file. See code
I'm trying to use slime from CVS (2009-01-05) but keep getting this error: LOAD:
I keep getting the above error when trying to transform XML that's generated in
I seem to be getting the above error when trying to make a callable
Getting the above error in following code. How to rectify it. Thanks. Please look
I am getting the above error whenever I test on an emulator, but not
In this header file, I am getting error: unknown type name uint32, uint16. I
I'm trying to have an auto reversing animation, and am getting the above error
I keep getting this error when trying to open a connection using entity framework.
probably a really dumb question, but I keep getting the above error with the

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.