I have the following code in my index view
public ActionResult Index(string searchBy, string search)
{
Session["FullName"] = search;
var dbsenderPostal = (from a in db.TblCUSTOMER_PROFILE
where a.FullName == search
select a.PostalAddress).ToArray();
Session["PostalAddress"] = dbsenderPostal;
if (searchBy == "XXX")
{
return View(db.TblCUSTOMER_PROFILE.Where(senders =>
senders.GeneratedCode == search || search == null).ToList());
}
else
{
return View(db.TblCUSTOMER_PROFILE.Where(senders =>
senders.CustomerFullName.StartsWith(search) || search ==
null).ToList());
}
}
In my [HttpPost] MorePost view, I am passing data to this 'MorePost' post controller using Sessions with the value pairs. If i add the .Split() method to 'ViewBag.messages2', another error occurs as " 'System.Array' does not contain a definition for split ". This is from further research online to solve this proble. Please am i doing anything wrong with my LINQ query to ViewBag which is passing data to the object name 'sentprint'. I am able to retrieve the data from the LINQ query as 'P.O.Box AX 33 Miami'. I have also tried using 'TempData'. like this TempData["PostalAddress"]. I did try other approaches which gives other errors as "Cannot implicitly convert type 'System.Data.Entity.Infrastructure.DbQuery' to 'string' ". Sorry I am new to LINQ query. Thanks in Advance.
[HttpPost]
public ActionResult MorePost(string Itemn)
{
TblSENDERSINFORMATION sentprint = new TblSENDERSINFORMATION();
ViewBag.messages = Session["FullName"];
sentprint.NameOfSender = ViewBag.messages;
ViewBag.messages2 = Session["PostalAddress"];
sentprint.PostalAddress = ViewBag.messages2; //Error found here
sentprint.Item = Itemn;
}