Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am Binding dropdownlist.
My code is
ASP.NET
<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
HTML
<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($("&lt;option>&lt;/option>").val(data[i].AllocValue).html(data[i].AllocationOrderNo));
}

}
});

}
else {
$("select[id$=ddlAllocationOrderNo] > option").remove();
}
}
catch (e) {

}

}</pre>

source code is

HTML
<option value="0">Select One</option>
<option value="1">123456</option>

select tag is not there.
Posted
Updated 14-Jan-16 0:45am
v2

1 solution

Remove Update Panel.



<asp:label runat="server" id="lblAllocationOrderNo" text="Allocation Order No." xmlns:asp="#unknown">


<asp:dropdownlist runat="server" id="ddlAllocationOrderNo" cssclass="form-control input-sm" xmlns:asp="#unknown">




<asp:requiredfieldvalidator id="rfvAllocationOrderNo" runat="server" controltovalidate="ddlAllocationOrderNo" xmlns:asp="#unknown">
ValidationGroup="frmSelection"
ErrorMessage="Allocation No. Required" CssClass="fa text-red" SetFocusOnError="True" Display="Dynamic"
InitialValue="0">




 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900