Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Post
Register
Login
5
Reply
combo box with default text
Enos
Dec 4 2014 4:19 AM
790
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)
{
}
}
Upload Source Code
Select only zip and rar file.
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