Currently I want my dropdown of the selected index to get its value and then send it to a query I have in entity framework.
But the problem is that I select my dropdownList and reload and therefore lose the selected value and that's why I always get 0, although I should not do it.
<asp:DropDownList ID="SelectMateria" OnSelectedIndexChanged="SelectMateria_OnSelectedIndexChanged" DataValueField="Id" DataTextField="Nombre" runat="server" CssClass="selectpicker form-control" AutoPostBack="True" data-style="btn-white" data-header="Materia" >
</asp:DropDownList>
Back code:
protected void SelectMateria_OnSelectedIndexChanged(object sender, EventArgs e)
{
IndexText.Text = SelectMateria.SelectedIndex.ToString();
}
When I sent my selectedindex to the input of asp it always gives me 0, I already tried to do it without the autopostback but it does not enter the method and with the property of EnableViewState="True" but it still did not work.