Hello friends this really basic question in mvc, but iam lot of search i couldn't find it.
Control:
if (objResponse.ErrorNo == 0)
{
lstReason.Add(new SelectListItem { Value = "1", Text = "Select" });
foreach (XElement xEle in resXml.Descendants("R"))
{
lstReason.Add(new SelectListItem { Value = xEle.Element("C1").Value, Text = xEle.Element("C2").Value });
}
ViewBag.ReasonCode = lstReason;
}
}
View:
@Html.DropDownListFor(m => m.ReasonCode, new SelectList(ViewBag.ReasonCode, "Value", "Text"), new { @class = "form-control autofocus", @id = "ddlReason"
})
I got it only m => m.ReasonCode
but how can get m.reason from ViewBag.ReasonCode text value.
Any help would be really appreciated.