I have a following aspx:dropdown in aspx file:
<asp:DropDownList ID="ddlbStatus" Width="210px" Height="30px" CssClass="ddlb"
runat="server" onselectedindexchanged="ddlbStatus_SelectedIndexChanged" Style="text-align:left">
<asp:ListItem Selected="True" Text="" Value="NA"> </asp:ListItem>
<asp:ListItem Text="New" Value="NEW"></asp:ListItem>
<asp:ListItem Text="Open" Value="OPEN"></asp:ListItem>
<asp:ListItem Text="Closed" Value="CLSD"></asp:ListItem>
</asp:DropDownList>
I want to populate it from my c# file. I tried it with the following code but it didn’t work for me:
ddlbStatus.SelectedItem = r["OrderPeriodStatus"].ToString();
For example r["OrderPeriodStatus"].ToString(); prints NEW or OPEN or CLOSED
I am newbie in asp.net. What i am doing wrong?
Updated
I have already three text present in dropdwonlist. Now what i want , I fetch the status from a SQL Query, and that value will be NEW CLOSED or OPEN. So, for example if i get the CLOSED value from database then in my HTML page CLOSED will be in selected region.
You can fill or populate your
DropdownlistinC#in this mannerEDIT: