I have made a simple dropdownlist with hard-coded Values and Text's as below:
<asp:DropDownList ID="MonthSelectionDrop" runat="server" EnableViewState="true" >
<asp:ListItem Value="0" Text="--please select--" />
<asp:ListItem Value="1" Text="January" />
<asp:ListItem Value="2" Text="February" />
<asp:ListItem Value="3" Text="March" />
<asp:ListItem Value="4" Text="April" />
<asp:ListItem Value="5" Text="May" />
<asp:ListItem Value="6" Text="June" />
<asp:ListItem Value="7" Text="July" />
<asp:ListItem Value="8" Text="August" />
<asp:ListItem Value="9" Text="September" />
<asp:ListItem Value="10" Text="October" />
<asp:ListItem Value="11" Text="November" />
<asp:ListItem Value="12" Text="December" />
</asp:DropDownList>
After I press a button, it automatically empties a label and then is meant to be filled with the relevant month. I do this using SelectedItem.Text as such:
MonthLabel.Text += MonthSelectionDrop.SelectedItem.Text + " ";
However, that returns the value of the item, rather then the text, unlike I'd expect.
I can't find the solution to this online, but I'm sure somebody knows how I can have my label show as 'January' rather then '1'
Edit: As per request I'll add my Button_Click event her for if it is usefull to others:
protected void SubmitSelect(object sender, EventArgs e)
{
if(CheckPresence()) //this is a function that return true at all times atm
{
MonthLabel.Text = "";
MonthLabel.Text += MonthSelectionDrop.SelectedItem.Text + " ";
MonthLabel.Text += YearTextBox.Text;
} else{
//To be implemented
}
}