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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:37:22+00:00 2026-05-16T04:37:22+00:00

Using C# & Mysql I have combobox & button in my webpage, if i

  • 0

Using C# & Mysql

I have combobox & button in my webpage, if i select a value from the combobox, then i click the button the page is refreshing, combobox value is changing.

For Example

Combobox value: 1, 2, 3, 4 .....

If i selected 2 then i press the button, webpage is refreshing, combobox values is display from: 1, 2, 3, 4....

Combobox should display 2

Why combobox is displaying a selected value when i press the button.

Table Name: user

Name username

Raja 1
Ravi 2
Ram 3
kumar 4
...,

Button click event code

cmd1 = new OdbcCommand("Select name from users where username = '" + combobox1.Items[combobox1.SelectedIndex].Text + "' ", dbcon);
            dr1 = cmd1.ExecuteReader();
            while (dr1.Read())
            {
                textbox1.Text = dr1.GetString(0);

            }
            dr1.Close();

The Above code is working, but if i select the value 2 from the combobox, then i press the button textbox should display ravi, but textbox is displaying Raja, and also combobox also refreshing, combobox is not displaying 1 instead of 2.

How to solve this issue.

Need C# code Help

  • 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-16T04:37:22+00:00Added an answer on May 16, 2026 at 4:37 am

    Understanding ASP.NET View State might be a useful read. Generally, you need to somehow store the entered values and restore then on page load.

    Given the fact that the button is reloading the entire page, wouldn’t it be more efficient to reload just a part of it instead?

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

Sidebar

Related Questions

I have been tasked to develop an interactive website using java & mysql: using
I've been using PHP & MySQL for ages and am about to start using
Using POSIX threads & C++, I have an Insert operation which can only be
I am using C# & MYSQL to develop a desktop application. In one of
I have a relatively light query that needs information from a local MySQL table
I'm using C# & .NEt 3.5. What is the difference between the OptionA and
I wrote an application server (using python & twisted) and I want to start
I've created an web authentication app using c# & asp.net and want to bounce
Is there an ASP.NET AJAX framework other than just using UpdatePanel & Friends or
I am using StringReplace to replace &gt and &lt by the char itself in

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.