jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Passing data to ASP.net function
Tagged: grid, javascript grid, jquery grid
This topic contains 1 reply, has 2 voices, and was last updated by Peter Stoev 9 years, 11 months ago.
Viewing 2 posts - 1 through 2 (of 2 total)
-
Author
-
I have the following code
.js file$('#showReportingData').click(function () { var date = $("#exportDate").val(); getReportingData(date); var offset = $("#showReportingData").offset(); $("#reportingData").jqxWindow({ position: { x: parseInt(offset.left) + 60, y: parseInt(offset.top) + 60 } }); $("#reportingData").jqxWindow('open'); }); function getReportingData(reportingDate) { var source_reportingdata = { datatype: "xml", datafields: [ { name: 'returnedEmployeeWages', type: 'string' }, { name: 'total', type: 'string' }, { name: 'comment', type: 'string' } ], data: { 'returnedDate' : reportingDate }, async: false, record: 'Table', url: 'ReturnedPays.aspx/GetReportingData' }; var reportingDataAdapter = new $.jqx.dataAdapter(source_reportingdata, { contentType: 'application/json; charset=utf-8' } ); $("#reportingData_grid").jqxGrid({ width: '100%', autoheight: true, source: reportingDataAdapter, theme: theme, autorowheight: true, autoheight: true, showstatusbar: true, statusbarheight: 50, altrows: true, showaggregates: true, columns: [ { text: 'Context', datafield: 'returnedEmployeeWages', width: '70%' }, { text: 'Total Count', datafield: 'total', width: '15%', aggregates: ['sum'] }, { text: 'Comments Count', datafield: 'comment', width: '15%', aggregates: ['sum'] } ] }); };
with the following code in an aspx page in c#
[WebMethod] [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Xml)] public static string GetReportingData(string returnedDate) { string query = @"SELECT * FROM [PayrollAccounting].[dbo].[reportingData] WHERE returnedDate = @returnedDate"; SqlCommand cmd = new SqlCommand(query); // Populate the DataSet. DataSet data = GetData(cmd, "PayrollAccountingConnectionString"); cmd.Parameters.AddWithValue("@returnedDate", returnedDate); // return the Customers table as XML. System.IO.StringWriter writer = new System.IO.StringWriter(); data.Tables[0].WriteXml(writer, XmlWriteMode.WriteSchema, false); return writer.ToString(); }
But when I perform the showReportingData button click I get “GET http://localhost:63058/ReturnedPays.aspx/GetReportingData?filterscount=0&gr…cordstartindex=0&recordendindex=18&returnedDate=2015-06-10&_=1433915831714 500 (Internal Server Error)” error.
I have followed examples to format the data, changed from xml to json to return but I am unable to get this to work correctly.
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.