I am Binding dropdownlist.
My code is
<asp:UpdatePanel ID="upd1" runat="server" >
<ContentTemplate> <div class="col-md-3">
<asp:Label runat="server" ID="lblAllocationOrderNo" Text="Allocation Order No."></asp:Label>
<asp:DropDownList runat="server" ID="ddlAllocationOrderNo" CssClass="form-control input-sm">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvAllocationOrderNo" runat="server" ControlToValidate="ddlAllocationOrderNo"
ValidationGroup="frmSelection"
ErrorMessage="Allocation No. Required" CssClass="fa text-red" SetFocusOnError="True" Display="Dynamic"
InitialValue="0">
</asp:RequiredFieldValidator>
</div>
</ContentTemplate>
</asp:UpdatePanel>
Before Binding it source code is
<select id="ContentPlaceHolder1_ddlAllocationOrderNo"></select>
there is no option
after Binding by given code
<pre lang="Javascript">
function getAllocationOrderN() {
try {
var fromdate = $('#<%=txtFromDate.ClientID%>').val();
var todate = $('#<%=txtToDate.ClientID%>').val();
var DFSO = $('#ContentPlaceHolder1_ddlDFSO :selected').val();
if (DFSO != '' & fromdate != '' & todate != '') {
$.ajax(
{
type: "POST",
contentType: "application/json; charset=utf-8",
url: "../scm/Search_CS.ashx?act=falloc&DFSO=" + DFSO + "&fromdate=" + fromdate + "&todate=" + todate,
data: "{}",
dataType: "json",
async: true,
selector: '#<%=ddlAllocationOrderNo.ClientID %>'
,
success: function (data) {
$("[id*=ddlAllocationOrderNo]").empty();
for (var i = 0; i < data.length; i++) {
$("[id*=ddlAllocationOrderNo]").append($("<option></option>").val(data[i].AllocValue).html(data[i].AllocationOrderNo));
}
}
});
}
else {
$("select[id$=ddlAllocationOrderNo] > option").remove();
}
}
catch (e) {
}
}</pre>
source code is
<option value="0">Select One</option>
<option value="1">123456</option>
select tag is not there.