Here i am using XML to load my dropdown values.During HTTPPost after loading these dropdown values from XML and all other model values becomes null and my model is only having these dropdown values.
[HttpPost]
public ActionResult Analyze(AnalyzeModels model)
{
if (ModelState.IsValid)
{
model.RequestID = ObjCommon.GenerateRequsetID(ObjSharedEntities.UserID, "ATA_1"); // Generation of the Request ID
}
model.ChartName = ObjCommon.GetFusionSWFReportName("ASTrend", "ATA_1");
var ppgFile = Server.MapPath(DataTemplate.PPGXmlPath);
var ppgItems =
from brand in XDocument.Load(ppgFile).Descendants("PPGItem")
select new SelectListItem
{
Value = brand.Element("Value").Value,
Text = brand.Element("Text").Value
};
model = new AnalyzeModels
{
PPGItems = ppgItems
};
return View(model);
}
Any suggestion?
In your code here:
you are creating a new instance of the model, which will effectively clear the values you have set.
Consider instead just doing this: