Hi
I have a dropdown list with select2 inside a grid view template item. I was able to populate it normaly from the back end on RowCreated event but when data grow it takes a while with each row to be populated specially when user add a new row.
Instead, I use AJAX to populate the dropdown list based on user input in the select2 search box which minimized data loading and it works perfectly.
My problem here is when a dropdown list populated in client side, Any post back event (index changed) throw the following error. It looks like server side doesn't see the populated items.
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
Here is the Ajax I use
JavaScript
<script type="text/javascript">
$(document).ready(function () {
$('.Accounts').select2({
ajax: {
url: '../cls/AutoComplete.asmx/Accounts',
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
delay: 500,
data: function (params) {
var search = '';
if (params.term !== undefined) {
search = params.term;
}
return "{'AccountName': '" + search + "','Level': '2'}";
},
processResults: function (data) {
var items = JSON.parse(data.d).items
if (items == null) {
return null;
}
return {
results: items
};
}
},
allowClear: true,
minimumInputLength: 3
});
});
</script>
Is there any solution, or any other suggested approach to achieve the same goal.