c# - AutoPopulate DropDownList Using Ajax -


i have 2 dropdownlist binded on pageload , want rebind these 2 dropdownlist after firing ajax function.here have written sql server stored procedure data needed dropdownlists.but how value dropdownlist,so can bind new data using ajax function.the screen developed using asp.net c# coding.

here drop down list of asp.net

<asp:dropdownlist id="ddlcourse" runat="server" autopostback="false"                                      height="28px" title="select course" width="290px"        ></asp:dropdownlist> 

and here jquery method calling web service method

function bindcourse() {     $.ajax({         type: "post",         url: "/webservice/collegewebservice.asmx/getcoursedetails",         data: "{}",         async: true,         contenttype: "application/json; charset=utf-8",         datatype: "json",         success: oncoursepopulated,               error: function (xml, textstatus, errorthrown) {             alert('error');             alert(xml.status + "||" + xml.responsetext);         }     }); } 

this method used in ajex call method , call populatecontrol method bind drop down list

function oncoursepopulated(response) {      populatecontrol(response.d,   $('#<%=ddlcourse.clientid %>'));  } 

here description of populatecontrol method

function populatecontrol(list, control) {      if (list.length > 0) {          control.removeattr("disabled");          control.empty().append('<option selected="selected" value="0">please select</option>');         $.each(list, function () {               control.append($("<option></option>").val(this['value']).html(this['text']));          });     }     else {         control.empty().append('<option selected="selected" value="0">not available<option>');     } } 

thus bind drop down list


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -