Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am making web application using C#.NET and SQL SERVER.
I have displayed the data which is stored in SQL SERVER.
Now the problem is data which is already in SQL should get only displayed just like read only, user should not add its own data in that combo box.
I have following code which is working properly.
What else should i do?

private void cbomedia_MouseClick(object sender, MouseEventArgs e)
        {


                SqlDataAdapter adp = new SqlDataAdapter("select *from Media_Method", "Data Source=SW-PC-20;Initial Catalog=PSM;Integrated Security=True");
                DataSet ds = new DataSet();


                adp.Fill(ds);

                cbomedia.DataSource = ds.Tables[0];
                cbomedia.DisplayMember = "Media_method_ID";

            }

or
Am I skipping any property?
Posted
Updated 1-May-11 23:50pm
v2
Comments
Ankit Rajput 2-May-11 5:45am    
Are you sure its a Web Application?
RAJI @Codeproject 2-May-11 6:02am    
if its a windows application change your Combobox dropdownstyle property to dropdown
Ankit Rajput 2-May-11 6:05am    
RAJI: I think you mistyped. This property should be set as DropDownList.

Hi,

If its a windows application then need to set property of combobox as
cmbBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;


Please try it.

Regards
AR
 
Share this answer
 
Comments
shivani 2013 2-May-11 6:16am    
thanks
Set the dropdownstyle to DropDownList for the Combobox.
 
Share this answer
 
Comments
shivani 2013 2-May-11 6:16am    
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900