Solved : DATATABLE PASSING PARAMETER IN JQUERY VIA WEBMETHOD C#

Solved : DATATABLE PASSING PARAMETER IN JQUERY VIA WEBMETHOD C#

pvuserpvuser Posts: 3Questions: 1Answers: 0

Hi all

I faced this issue in the last 3 days. finally i find it the solution and posted it for all

$("#<%=TeamCategoryList.ClientID %>").change(function ()
{
var tcatList = document.getElementById("<%=TeamCategoryList.ClientID %>");
var obj1 = { teamid: $('#TeamList').val(), teamcategoryid: tcatList.value };
$('#mytestreport').DataTable({
"processing": false,
"serverSide": false,
"ajax":
{
"type": "POST",
"contentType": "application/json; charset=utf-8",
"url": "MyTeamReport.aspx/GetReportbyId",
"dataSrc": "d", //IMPORTANTTTTTTTTTTTTTTTTTTTTTTT
"data": function (d) {
return JSON.stringify(obj1);
}, //IMPORTANTTTTTTTTTTTTTTTTTTTTTTT
"dataType": 'json',
"paging": true,
"lengthChange": false,
"searching": true,
"ordering": true,
"info": true,
"autoWidth": false
},
"aoColumns": [
{ "data": "TestCreatedDate", "title": "TestCreated Date" },
{ "data": "TestName", "title": "Test Name" },
{ "data": "EmployeeCode", "title": "Employee ID" },
{ "data": "EmployeeName", "title": "Employee Name" },
{ "data": "Desgination", "title": "Desgination" },
{ "data": "TotalMark", "title": "TotalMark" },
{ "data": "ScordMark", "title": "Score" },
{ "data": "Result", "title": "Pass/Fail" },
{ "data": "TestAttenddate", "title": "TestAttend Date" },
{ "data": "TestAssignby", "title": "Test Assignby" },
]});

    });

[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)] //IMPORTANTTTTTTTTTTTTTTTTTTTTTTT
public static List<ReportModel> GetReportbyId(string teamid,string teamcategoryid)
{

        return ReportBAL.GetReportbyId(HttpContext.Current.Session["EmployeeCode"].ToString(), teamid, teamcategoryid);





    }

Replies

  • pvuserpvuser Posts: 3Questions: 1Answers: 0

    Please find the above solution

    Dont forgot to mention
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]

This discussion has been closed.