In my MVC program I need to grab datas one by one.But I'm facing "argumentexception was unhandled by user code" exception.I cannot solve it.The exception is coming on
int len=obj.sort.Count()
How can I solve this.
What I have tried:
public class KendoSort
{
public string field { get; set; }
public string dir { get; set; }
public string compare { get; set; }
}
public class dataObject
{
public int page { get; set; }
public int pageSize { get; set; }
public int take { get; set; }
public int skip { get; set; }
public List<kendosort> sort { get; set; }
}
//
// GET: /License/GetLicView
// JSON Result
[Authorize]
public ActionResult GetLicView(dataObject obj)
{
if (Session["FirstName"] != null && Session["userId"] != null && Session["guid"] != null)
{
string guid = (string)Session["Guid"];
List<getalllicensesdetailsforroles_result> lic = new List<getalllicensesdetailsforroles_result>();
lic = manager.GetuserLicensesDetails(guid, user.getuserrole(Guid.Parse(guid)));
int take = 20;
int skip = 0;
take = obj.take;
skip = obj.skip;
int end = take+skip; // 0+20
int len = obj.sort.Count();
for (int i = 0; i < len; i++)
{
var item = obj.sort[i];
if (item.field == "Start_Date" && item.dir == "asc")
{
lic = lic.OrderBy(x => x.Start_Date).ToList();
}
else
{
lic = lic.OrderByDescending(x => x.Start_Date).ToList();
}
}