drop down
-
Hi, A drop down list is populated using datasource as below ddlUsers.DataSource = Membership.GetAllUsers ddlUsers.DataBind() But now I want the drop down to show the following item as the first item. If I just use the following line, it gets added to the last item in the list. ddlUsers.Items.Add("<-- select a user -->") Thanks
-
Hi, A drop down list is populated using datasource as below ddlUsers.DataSource = Membership.GetAllUsers ddlUsers.DataBind() But now I want the drop down to show the following item as the first item. If I just use the following line, it gets added to the last item in the list. ddlUsers.Items.Add("<-- select a user -->") Thanks
-
Hi, A drop down list is populated using datasource as below ddlUsers.DataSource = Membership.GetAllUsers ddlUsers.DataBind() But now I want the drop down to show the following item as the first item. If I just use the following line, it gets added to the last item in the list. ddlUsers.Items.Add("<-- select a user -->") Thanks
Hi, Before binding value to the dropdown write the below code,
ddlUsers.Items.Clear();
newListItem = new ListItem();
newListItem.Value = "----Select a user---";
newListItem.Text = "----Select a user----";
ddlUsers.Items.Add(newListItem);ddlUsers.DataSource = Membership.GetAllUsers
ddlUsers.DataBind()Hope this helps u .. :)
-
Hi, A drop down list is populated using datasource as below ddlUsers.DataSource = Membership.GetAllUsers ddlUsers.DataBind() But now I want the drop down to show the following item as the first item. If I just use the following line, it gets added to the last item in the list. ddlUsers.Items.Add("<-- select a user -->") Thanks
-
Hi, Before binding value to the dropdown write the below code,
ddlUsers.Items.Clear();
newListItem = new ListItem();
newListItem.Value = "----Select a user---";
newListItem.Text = "----Select a user----";
ddlUsers.Items.Add(newListItem);ddlUsers.DataSource = Membership.GetAllUsers
ddlUsers.DataBind()Hope this helps u .. :)
-
hi, You can add this line to get the desired result. ddlUsers.Items.Insert(0,new ListItem("-- select a user --","0")); Hope this will solve your problem.:) Best Regards, Apurva Kaushal