sAjaxSource
sAjaxSource
rlatigano
Posts: 7Questions: 0Answers: 0
hi, i have problem retrieve data with sAjaxSource Im using .net 2010 WebForm Non MVC. using WebMethod
here my code
$('#myDataTable').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": 'User.aspx/GetInfo',
"aoColumns": [
{ "sTitle": "FullName", "mDataProp": "FullName", "sWidth": "20%" },
{ "sTitle": "Email", "mDataProp": "Email", "sWidth": "20px", "bSearchable": false, "bSortable": false },
{ "sTitle": "Phone", "mDataProp": "Phone", "sWidth": "20%", "bSearchable": false, "bSortable": false },
{ "sTitle": "OfficeName", "mDataProp": "OfficeName", "sWidth": "20%", "bSearchable": false },
{ "mDataProp": null, "sDefaultContent": "Edit", "sWidth": "20px", "bSearchable": false, "bSortable": false },
{ "mDataProp": null, "sDefaultContent": "Delete", "sWidth": "20px", "bSearchable": false, "bSortable": false }
]
}).makeEditable();
ServerSide
[WebMethod]
public static string GetInfo()
{
try
{
SqlParameter[] dbParams = new SqlParameter[]
{
DBHelper.MakeParam("@Saa", SqlDbType.Int, 0, 176)
};
DataSet ds = DBHelper.ExecuteDataSet("myStored", dbParams);
string result = Jayrock.Json.Conversion.JsonConvert.ExportToString(ds.Tables[0].Rows);
return result;
}
catch (Exception ex)
{
//sResult[0] = "error";
//sResult[1] = ex.Message;
return ex.Message;
}
}
here my code
$('#myDataTable').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": 'User.aspx/GetInfo',
"aoColumns": [
{ "sTitle": "FullName", "mDataProp": "FullName", "sWidth": "20%" },
{ "sTitle": "Email", "mDataProp": "Email", "sWidth": "20px", "bSearchable": false, "bSortable": false },
{ "sTitle": "Phone", "mDataProp": "Phone", "sWidth": "20%", "bSearchable": false, "bSortable": false },
{ "sTitle": "OfficeName", "mDataProp": "OfficeName", "sWidth": "20%", "bSearchable": false },
{ "mDataProp": null, "sDefaultContent": "Edit", "sWidth": "20px", "bSearchable": false, "bSortable": false },
{ "mDataProp": null, "sDefaultContent": "Delete", "sWidth": "20px", "bSearchable": false, "bSortable": false }
]
}).makeEditable();
ServerSide
[WebMethod]
public static string GetInfo()
{
try
{
SqlParameter[] dbParams = new SqlParameter[]
{
DBHelper.MakeParam("@Saa", SqlDbType.Int, 0, 176)
};
DataSet ds = DBHelper.ExecuteDataSet("myStored", dbParams);
string result = Jayrock.Json.Conversion.JsonConvert.ExportToString(ds.Tables[0].Rows);
return result;
}
catch (Exception ex)
{
//sResult[0] = "error";
//sResult[1] = ex.Message;
return ex.Message;
}
}
This discussion has been closed.