• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 321
  • Last Modified:

How do i set the default text for my asp.net dropdownlist

I wish to append the following to my dropdownlist

"--Please select one--"

As you see in the code below i am binding the dropdown with members. But this seems to override the new list item
List<Member> members = MemberController.GetMembers();
            DropDownListMembers.DataSource = members;
            DropDownListMembers.DataTextField = "LoginName";
            DropDownListMembers.DataValueField = "Id";
            DropDownListMembers.Items.Insert(0, new ListItem("--Please select one--", ""));
            DropDownListMembers.DataBind();

Open in new window

0
frosty1
Asked:
frosty1
1 Solution
 
masterpassCommented:
A small change would do the trick
List<Member> members = MemberController.GetMembers();
DropDownListMembers.DataSource = members;
DropDownListMembers.DataTextField = "LoginName";
DropDownListMembers.DataValueField = "Id";
DropDownListMembers.DataBind();
DropDownListMembers.Items.Insert(0, new ListItem("--Please select one--", ""));

Open in new window

0
 
frosty1Author Commented:
great, thanks :)
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Tackle projects and never again get stuck behind a technical roadblock.
Join Now