0
I own a dropdownlist
which is dynamically filled after two textboxes
have been filled in.
When I do form Ubmit the dropdownlist
is empty, even if dynamically filled.
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));
});
The form Submit is a one button click event.
How do I make sure that when dynamically filling the data, it persists in the form Ubmit ?
What do you mean persist in Submit? Keep value after page reload?
– Leandro Angelo
The form is posted by clicking a button that triggers an on click event, in this event the dropdownlist is already empty, it should be filled in to be validated and go to a new page.
– LP. Gonçalves
I believe that if you are populating your dropdown in the client, this control needs to be within a <form> tag and you will only recover this value on the server through a Request
– Leandro Angelo
This I fill on the client side, the dropdownlist tag is inside the <form> tag, How to do this last step that spoke ?
– LP. Gonçalves
Adds the method where you are retrieving form information after Submit
– Leandro Angelo