Click here to Skip to main content
15,889,808 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm developing the master detail data entry form without using entityframwork. I have two tables deal making and deal details for this purpose and i have developed two model classes for master and detail and when I pass the values of master and detail to the controller using ajax call. its going well and all records are coming in the controller I check it by putting a breakpoint. but the issue is this it's not going inside while checking model state. It gives model state false and giving the error of " Results View = Expanding the Results View will enumerate the IEnumerable."

please help me as soon as possible

public JsonResult Create( ClsDealMaking clsDeal ) {
 if (ModelState.IsValid){
//error here  model state is false not understanding the reason
}

return Json(JsonRequestBehavior.AllowGet); }


What I have tried:

public class ClsDealMaking
    {
        public int DealSysSeq { get; set; }
        public string DealCode { get; set; }
        public string DealName { get; set; }
        public DateTime ActiveFromDate { get; set; }
        public DateTime ActiveToDate { get; set; }
        public double TotalCost { get; set; }
        public double Discount { get; set; }
        public double Dealoffer { get; set; }
        public string Remarks { get; set; }
       // public Byte[] DealImage { get; set; }
        public virtual ICollection<clsDealDetail> DealDetails { get; set; }
    }
Posted
Updated 22-Sep-19 11:11am
Comments
Dave Kreskowiak 22-Sep-19 17:09pm    
That's not an error at all. That's a "placeholder" message the debugger puts up to show you that that is a collection or IQueryable hasn't been executed yet.
Samps Pro 24-Sep-19 1:29am    
but im not getting it.please explain

1 solution

The ModelState.IsValid is false because the data that was passed back from the page the client was looking at doesn't fit the restrictions on the model it's supposed to be filling in, namely your cldDeal (ClsDealMaking).

You should not be using entity objects as your view objects to pass data back and forth between the view and controllers. You should be making a separate set of class for this purpose.
 
Share this answer
 
v3
Comments
BillWoodruff 23-Sep-19 0:01am    
+5
Samps Pro 23-Sep-19 3:15am    
u means liike this
but not getting it please explain
public class masterdetail
{
List <clsdealmaking> MAsterdeal{ get; set; }
List<clsdealdetail> detailDeal{ get; set; }

}
Samps Pro 23-Sep-19 0:56am    
not understand please give some more explanation to solve it and also how to access both master detail classes can i access in controller using this new class
my detail class is as follow
Dave Kreskowiak 23-Sep-19 10:51am    
What data is the view returning to the controller? You need to create a class that has the appropriate properties to hold that data. These classes would be specifically for the purpose of transferring data between your controllers and the view and back again. They should have properties for the data the view needs to edit and any additional data the view needs to edit that data.

Do not use Entity Framework classes for this purpose. Entity classes are for going between your controllers and the database.
Samps Pro 23-Sep-19 0:57am    
public class clsDealDetail
{
public int DetailSysSeq { get; set; }
public int DealSysSeq { get; set; }
public int ItemSysSeq { get; set; }
public int Qty { get; set; }
public double UnitPrice { get; set; }
public virtual ClsDealMaking DealMaking { get; set; }
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900