Reputation: 15
My code is below getting list of data from mysql, I got this data here but I can't received in controller?
public static ReportViewModel GetReportList(string refno)
{
ReportViewModel reportModel = null;
DataTable dt = DataAccessLayer.FillData_table("select newmembership.name,concat(newmembership.addr1,', ',newmembership.addr2,) where newmembership.enrolledby='" + refno + "' and newmembership.m_status!='D' and newmembership.fm_type='PM' and newmembership.enrollmentno!='';");
List<object> resultsrow = dt.AsEnumerable().ToList<object>();
resultsrow = reportModel.resultsrow;
return reportModel;
}
Upvotes: 1
Views: 96
Reputation: 15
i got double values how to fix this
{
"Result": {
"resultsrow": [
{
"RowError": "",
"RowState": 2,
"Table": [
{
"refno": "091271788888",
"name": "S Santhosh kumar",
},
{
"refno": "0912717006555",
"name": "ggg",
}
],
"ItemArray": [
"091271788888",
"S Santhosh kumar",
],
"HasErrors": false
},
{
"RowError": "",
"RowState": 2,
"Table": [
{
"refno": "091271788888",
"name": "S Santhosh kumar",
},
{
"refno": "0912717006555",
"name": "ggg",
}
],
"ItemArray": [
"0912717006555",
"ggg",
],
"HasErrors": false
}
]
},
"Message": "",
"Success": true
}
Upvotes: 0
Reputation: 1985
I think, you are getting NullPointerException in your GetReportList method as you are not initializing reportModel. Please try this:
public static ReportViewModel GetReportList(string refno)
{
ReportViewModel reportModel = new ReportViewModel(); // reportModel instance is created here.
DataTable dt = DataAccessLayer.FillData_table("select newmembership.name,concat(newmembership.addr1,', ',newmembership.addr2,) where newmembership.enrolledby='" + refno + "' and newmembership.m_status!='D' and newmembership.fm_type='PM' and newmembership.enrollmentno!='';");
reportModel.resultsrow = dt.AsEnumerable().ToList<object>();
return reportModel;
}
If you could show us ReportViewModel definition and the place where you are invoking GetReportList then we could help further.
Upvotes: 1