I have an aspx page (C # code page). I have some hardcoded dropdownlists and for some reason they do not display the top of the list (value). I added an additional top list item (value), and now the correct values are displayed for existing values, but this additional is not displayed.
The only function that I perform with my dropdownlists in my C # code is to hide or show them. And then check whether or not based on the selected value.
My aspx code:
<asp:DropDownList ID="ddlAction" runat="server" Visible="True"
AppendDataBoundItems="true" Height="25px" Width="149px">
<asp:ListItem Value="Select">Please Select</asp:ListItem>
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:DropDownList>
C # code:
ddlAction.Visible = false;
ddlAction.Visible = true;
I use dropdownlist regularly and have never had this problem before. Does anyone have any ideas what might be the problem?
UPDATE IN THIS ISSUE:
# Rahul. , .
( ", " ).
Aspx:
<asp:DropDownList ID="ddlAction" runat="server"
AppendDataBoundItems="True" Height="27px" Width="159px">
</asp:DropDownList>
#:
ddlAction.Visible = true;
ddlAction.AppendDataBoundItems = true;
ddlAction.Items.Insert(0, new ListItem("Please Select","Select"));
ddlAction.Items.Insert(1, new ListItem("Yes", "Yes"));
ddlAction.Items.Insert(2, new ListItem("No", "No"));
ddlAction.DataBind();
:
<select name="ctl00$ContentPlaceHolder1$ddlAction" id="ContentPlaceHolder1_ddlAction" style="height:27px;width:159px;">
<option selected="selected" value="Select"></option>
<option value="Yes">Yes</option>
<option value="No">No</option>