简体   繁体   中英

DropDown filled with AJAX does not postback its values?

I have an asp Dropdown that I fill at runtime on the client via ajax.

When I postback to my codebehind though it does not have any values and no selected value.

I could dump and parse the values into a hidden field but is there a better way?

Thanks

In code behind:

protected void btnEdit_Click(object sender, EventArgs e)
{
    elemSchedule = ScheduleManager.GetSchedule(elemScheduleID);
    KezErrorList errors = new KezErrorList();

    using (var scope = new TransactionScope())
    {
        try
        {
            int priority = int.Parse(ddlPriority.SelectedValue);

In frontend:

            fillPriorityList("#<%= ddlPriority.ClientID %>",
   $("#<%= txtID.ClientID %>").val(), $("#<%= ddlEmp.ClientID %>").val(),
             $("#<%= txtStartDate.ClientID %>").val(), $("#<%= txtPriority.ClientID %>").val());

Can you try using the Updatepanel Ajax instead of jQuery Ajax and see if you are still facing the issue? I believe the data is out of sync for the dropdown between the client and the server.

(Assuming you are using asp.net webforms) you need to make sure that you put the same values that you put on the client (via ajax) also on the server. Otherwise you would get the effect that you are describing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM