TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sandep Patidar
NA
2
7.2k
how to upload a text file from jqgrid usin c# web method .
Jan 12 2015 10:02 AM
I am trying to upload a text file from JQgrid edittype file option. But when clicking on submit button on add dialoge its not calling web method. Please help.
Below is my code:
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
)
{
}
Please hot to call web method to upload file in database.
Reply
Answers (
0
)
Dynamically create control and set id for control in asp.net
Can someone please help me how to upload file from jqgrid