I have a dropdownlist
that is populated dynamically after two textboxes
have been filled.
When I submit the form the dropdownlist
is empty even though it is filled dynamically.
DropDownList
<asp:DropDownList ID="DropDownListReason" runat="server" CssClass="span8">
<asp:ListItem Text="Selecione o motivo da solicitação" Value=""></asp:ListItem>
</asp:DropDownList>
Render
protected override void Render(HtmlTextWriter writer)
{
//busca lista de dados
foreach (var item in listaDeDados)
{
Page.ClientScript.RegisterForEventValidation(this.DropDownListReason.UniqueID, item.Id.ToString());
}
base.Render(writer);
}
Jquery
//faz o get dos dados
$.each(response, function (key, value) {
if (value.requiresDescription) {
requiresDescription.push(value.id);
}
$("#<%= DropDownListReason.ClientID %>").append($("<option />").val(value.id).text(value.description));
});
Form submit is an event on the click of a button.
How do I dynamically fill in the data, do they persist in submitting the form?