Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everybody,

I have a Model Class Payment in which have a property ProductItems that is assigned in a Constructor. It is working fine in get method but when i am Submit this view then In Post Action i am not able to get the values of this property.

public class Payment 
{
public Payment()
{
//Get the Value from the Static Method and set into the property.
ProductItems = StaticClass.StaticMethod();
}
public list<items> ProductItems  {get;set;}
}


//Here is the place where i am not able to get the value of Property : In Controller
[HttpPost]
public ActionResult Index (Payment paymentobj)
{
//Here i am getting payment.ProductItems Value is null  ???

}
Posted

1 solution

paymentobj will be filled in through model binding. You need to make sure that your objects are correctly serialized coming from the view (the form) where the data is being created/manipulated. This includes correct casing, proper structure of the form, etc.

If you set a breakpoint in that [HttpPost] method (or get Fiddler2 running, or use browser tools), you will be able to see the actual request in the POST which is how you will be able to troubleshoot this one.

Unfortunately, without seeing your view or information on how your data is getting to the Index method it will be hard to get a concise, direct answer.

Cheers.
 
Share this answer
 
Comments
Anubhava Dimri 22-Oct-13 10:50am    
May i know how can i do that?

I have apply the Serialize attribute at the top of items Class.
Anubhava Dimri 24-Oct-13 5:41am    
Hi,
I create an object of Payment on Post. In this object having all values are available in ProductItems Property.
when i use updatemodel(paymentobj). and then the property values was not available.

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