Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Post
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
5
Reply
combo box with default text
Enos
9 years ago
797
Reply
Hi ,
i have a combo box which loads from the database. Now i want default text on the combo box ("--Please Select--") to appear on top of the list, it must show the text whithout the user even opened the combo box. Also when the user clear the combo box, the default text will be "--Please Select--"
this is how i bindeed it ;
private void LoadCombo()
{
try
{
oConnection = new SqlConnection(_connectionString);
oCommand = new SqlCommand("select * from tbldpt", oConnection);
oAdapter = new SqlDataAdapter(oCommand);
oConnection.Open();
oDataset = new System.Data.DataSet();
SqlDataReader oReader = oCommand.ExecuteReader();
while (oReader.Read())
{
string _Combobox = oReader["Departmentname"].ToString();
cboDepartment.Items.Add(_Combobox);
}
oReader.Close();
oConnection.Close();
}
catch(Exception ex)
{
}
}
Post
Reset
Cancel
Answers (
5
)
Next Recommended Forum
How to type Telugu language in aspx page..Please tell me
Ho to download aspx as pdf