We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Combobox in DataGridView

Mr_Bach
Mr_Bach asked
on
Medium Priority
1,090 Views
Last Modified: 2012-05-06
Hi, below is my code, I have column: Condition in table of SQL server, I want when I press button1, the column Condition will be showed like combobox with Items list created in C#.

How Can I do?
private void button1_Click(object sender, EventArgs e)
        {
            String sql = "select * from Main";
            
            try
            {
                SqlConnection c = new SqlConnection(ConnectionString);
                adap = new SqlDataAdapter(sql, c);
                SqlCommandBuilder cb = new SqlCommandBuilder(adap);
                if (c.State == ConnectionState.Closed)
                    c.Open();
                dt = new DataTable();
                adap.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please select Date " + ex.Message);
            }
    
        }

Open in new window

Comment
Watch Question

anarki_jimbelSenior Developer
CERTIFIED EXPERT

Commented:
Senior Developer
CERTIFIED EXPERT
Commented:
Honestly, what I don't like is  when experts give some info and ask a questions to help the asker and never get reply. Then after a while  - the question is closed because of "No answer". And there is a feeling that this info might be used but nobody wanted to allocate points. Might be not - but who knows, no feedback what so eve (BTW, I'm not claiming any points - just my thoughts). A bit of respect would be good...

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.