我必須在jqModal彈出框中綁定asp.net gridview和jquery 我做了一個ajax post調用並獲取一個列表。 我需要將此列表綁定到asp.net網格,以便成功回調ajax調用。 請在下面找到我使用的代碼,在bindGrid方法中,我需要將列表綁定到asp.net gridview。 請幫忙!如何使用jQuery綁定asp.net gridview控件?
功能頁面加載(發件人,參數){
var param = null;
$(function() {
var myBlock = $('#myBlock'); // cache jq obj
$().ajaxStart(function() {
$.blockUI(myBlock);
}).ajaxStop($.unblockUI);
});
var showModalPopup = function (container, path, leftMargin, topMargin, triggerElement, postData) {
// alert('in popup');
//(container, path, leftMargin, topMargin, triggerElement, postData) {
///<summary>This method is used for displaying remote pages in modal popup.</summary>
///<param name="container">ID of the div which is displayed as popup.</param>
///<param name="path">URL of the page which will be displayed as popup.</param>
///<param name="leftMargin">Width of left margin in "%". Used for alignment of popup.</param>
///<param name="topMargin">Width of top margin in "%". Used for alignment of popup</param>
///<param name="triggerElement">Element which triggered the popup. Used for contexts.</param>
///<returns></returns>
var divBlock = '#' + container;
if (typeof leftMargin === 'undefined') {
leftMargin = '20%';
}
if (typeof topMargin === 'undefined') {
topMargin = '10%';
}
//if the 3rd parameter type is object,we would treat it as postdata
if (typeof leftMargin === 'object') {
postData = leftMargin;
leftMargin = '10%';
}
if (typeof triggerElement !== 'undefined') {
//Select the id of immediate fieldset of the element which opened popup.
//e.g., if "NameSearchButton" is the trigger element, find the fieldset containing this button.
var parentFieldsetId = triggerElement.parents('fieldset')[0].id;
//Store the fieldset by adding it as custom attribute to divPopup.
$(divBlock).attr('parentContext', parentFieldsetId);
}
$.blockUI({ message: $(divBlock),
css: {
padding: 10,
margin: 0,
left: leftMargin,
top: topMargin,
width: '',
height: '',
centerX: true,
centerY: true,
textAlign: 'center',
color: '#000',
opacity: '80',
border: '3px solid #aaa'
},
overlayCSS: {
backgroundColor: '#000',
opacity: 0.7
},
fadeIn: 0,
fadeOut: 0
});
if (path !== 'local') {
$(document).data('formInstance', false);
if (postData) {
$.post(path, postData, function (response) {
$(divBlock).html(response);
});
}
else {
$(divBlock).load(path);
}
}
$(divBlock).attr('IsPopupDiv', 1);
};
var bind = function (success) {
if (success !== null || success !== undefined) {
//Bind to the grid #ContentPlaceHolder1_grdPopUpGrid
}
};
var bindGrid = function() {
var objBind = '06'; //$('#ContentPlaceHolder1_txtBeginsWithText').val();
var conStrBind = $('#ContentPlaceHolder1_ConnStrHidden').val();
if (param == null || param == '' || param == undefined) {
drpParamBind = $('#ContentPlaceHolder1_drpSearchBy').val();
}
else {
drpParamBind = param;
}
var webMethodURL = 'testPage.aspx/HitMethod';
var newobj = { 'obj': objBind, 'conStr': conStrBind, 'drpParam': drpParamBind };
$.ajax({
type: "POST",
url: webMethodURL,
contentType: "application/json; charset=utf-8",
data: JSON.stringify(newobj),
dataType: "json",
success: function (response) {
var success = '';
if (response !== undefined) {
if (response.d !== null || response.d !== '') {
success = response.d;
bind(success);
}
}
}
// ,error: function(XHR, errStatus, errorThrown) {
// }
});
};
var con = $('#imgSearchSpouse').parent();
var test = $('#txtPartnerNo').val();
$("#ContentPlaceHolder1_imgSearchSpouse").click(function() {
// alert('hello');
showModalPopup('ContentPlaceHolder1_Spousepopupdiv', 'local', '13%', '15%');
});
$('#ContentPlaceHolder1_btnSearchpopup').click(function() {
bindGrid();
});
}
</script>