Hi friends
I want to know, how to show default value in dropdownlist in HTML ? Example-suppose there are a dropdownlist for male/female, I want to show default value i.e. --sex-- in dropdownlist ? Please tell me anyone ?
Thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Lajapathy ArunPosted May 4, 2012, 4:30 AM
Vineet Kumar SainiPosted May 4, 2012, 5:36 AM
SenthilkumarPosted May 4, 2012, 4:28 AM
In HTML, you have the control called option.
Where you can have the set of options with default selected value.
Try this..
For other properties about option, go here.
Jignesh TrivediPosted May 4, 2012, 3:48 AM
u can do same thing just adding one record in data source of drop down list.
example if u use data table to bind drop down then add one row to that table.
DataRow datarow = dt.NewRow();
datarow["valueFiled"] = 0;
datarow["TextFiled"] = "--sex--";
dt.Rows.InsertAt(datarow, 0);
drpEmpId.DataSource = dt;
drpEmpId.DataTextField = "valueFiled";
drpEmpId.DataValueField = "TextFiled";
drpEmpId.DataBind();
hope this help.