{"__type":"CountryModel","dt":null,"ds":null,"dtRow":null,"strSQL":{"Capacity":16,"MaxCapacity":2147483647,"Length":0},"iCnt":0,"ConnType":"FP","Code":"AE","Value":"United Arab Emirates"},{"__type":"CountryModel","dt":null,"ds":null,"dtRow":null,"strSQL":{"Capacity":16,"MaxCapacity":2147483647,"Length":0},"iCnt":0,"ConnType":"FP","Code":"AF","Value":"Afghanistan"},{"__type":"CountryModel","dt":null,"ds":null,"dtRow":null,"strSQL":{"Capacity":16,"MaxCapacity":2147483647,"Length":0},"iCnt":0,"ConnType":"FP","Code":"AG","Value":"Antigua and Barbuda"},
this is the webmethod that I return by json, but the problem is, asp.net return value from base class that I inherit from, how to solve this? although is working, but the data are wasted as I don't wish to return the value, any idea?
BaseModel.cs
public string ConnType="";
public datatable dt;
CountryModel.cs:
public class CountryModel:BaseModel{
public List<MenuFunctionModel> AssignList()
{
var _List = new List<MenuFunctionModel>();
foreach (DataRow dr in dt.Rows)
{
_List.Add(new MenuFunctionModel
{
Code = dr["Code"].ToString(),
Title = dr["Title"].ToString(),
Description = dr["Description"].ToString(),
Location = dr["Location"].ToString() + dr["FileName"].ToString()
});
}
return _List;
}
}
webservices api:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static List<CountryModel> loadCt()
{
CountryModel _Country = new CountryModel();
_Country.SelectAll();
return _Country.AssignList();
}
MenuFunctionModel?List<CountryModel>) you have used in webmethod. you can use another class that contains only required number of fields, or use anynomous type