0
我想從JQgrid edittype文件選項上傳文本文件。但是當我點擊提交按鈕時,on add dialoge
沒有調用Web方法。請幫忙。不能從jqgrid上傳文件到數據庫使用C#
下面是我的代碼:
GRID:
jQuery("#JQGridFileUpload").jqGrid({
postData: { searchString: '', searchField: '', searchOper: '' },
datatype: function (postdata) {
grid = $("#JQGridFileUpload")[0]; //its an array which contain binding data
grid.addJSONData(objClientDocumentData);
},
jsonReader: {
root: "rows",
page: "page",
total: "totalpages",
records: "totalrecords",
cell: "cell",
id: "ClientDocumentid", //index of the column with the PK in it
userdata: "userdata",
repeatitems: true
},
height: 'auto',
width: 'auto',
colNames: ['ClientID', 'Document Type', 'Document Description', 'View/Upload documents'],
colModel: [
{
name: 'ClientID', index: 'ClientID', width: 30, hidden: true,
edittype: 'text', editable: true
},
{
name: 'DocumentType', index: 'DocumentType', width: 30, editable: true,
edittype: 'select', editoptions: { value: ClientDocumentType }
},
{
name: 'DocumentName', index: 'DocumentName', width: 30, editable: true,
edittype: 'file', editoptions: {
enctype: "multipart/form-data"
},
formatter: 'showlink',
formatoptions: { baseLinkUrl: 'javascript:', showAction: "ShowFile('", addParam: "');" }
}
],
rowNum: 10,
loadonce: true,
pager: '#JQGridFileUploadPager',
sortname: 'DocumentType',
hidegrid: false,
sortorder: 'desc',
editurl: 'ClientMaster.aspx/UpdateDocumentDetails',
viewrecords: true,
caption: "Upload File",
gridComplete: function() {
...
}
});
$('#JQGridFileUpload').jqGrid('navGrid', '#JQGridFileUploadPager', ...)
{
edit: true,
add: true,
del: true,
search: false,
refresh: true
},
//Edit functionality
{
...
},
//Add functionality
{
url: 'ClientMaster.aspx/InsertDocumentDetails',
closeAfterAdd: true,
reloadAfterSubmit: false,
closeAfterAdd: true,
afterSubmit: function (options, postData, response) {
var filename = $("#DocumentName").val();
var files = $("#DocumentName").val();
$.fn.ajaxFileUpload
(
{
url: 'ClientMaster.aspx/InsertDocumentDetails1',
secureuri: false,
fileElementId: 'DocumentName',
dataType: 'json',
async: false,
success: function (data, status) {
if (typeof (data.error) != 'undefined') {
if (data.error != '') {
alert(data.error);
} else {
alert(data.msg);
}
}
},
error: function (data, status, e) {
debugger;
alert(e);
}
}
);
return [true, '', false];
}
},
//Delete functionality
{
}
});
}
//////////////////////////////////////////////////////
This is my web method which is not getting called:
[WebMethod]
public static void InsertDocumentDetails(
HttpPostedFileBase files
)
{
...
}
我應該如何調用Web方法上載文件到數據庫?