This is my first MVC project, and I am having trouble getting my view page to display a variable value from my model that is passed to the view by my controller. The value is being set properly in the controller, and the model being passed to the view contains the correct data when viewing in debug. But the view only displays the name of the variable and not the value. I'm really stuck. Here is my relevant code:
Model:
namespace namespace.Models
{
public class LatestRunInfoModel
{
public string LastRunDate { get; set; }
}
}
Helper Class:
public static class Helpers
{
public static string GetLastRunInfo()
{
_OracleConnectionString = dbConnect.OraCianbroC9i_ConnectionString;
using (OracleDataAdapter b = new OracleDataAdapter("ME.Namespace.Function", _OracleConnectionString))
{
b.SelectCommand.Parameters.Add(new OracleParameter("pResults", OracleDbType.RefCursor)).Direction = ParameterDirection.Output;
DataTable tbl1 = new DataTable();
b.SelectCommand.CommandType = CommandType.StoredProcedure;
try
{
b.Fill(tbl1);
string rundate = tbl1.Rows[0]["LAST_RUN_DATE"].ToString();
string runby = tbl1.Rows[0]["LAST_RUN_USER"].ToString();
return rundate.ToString();
}
finally
{ }
}
}
}
Controller Action that sets the variable:
public ActionResult About()
{
ViewBag.Message = "Message";
xxx.HLP_Vitality.BLL.myfunction("XXXXX", 18, 2016, true);
LatestRunInfoModel myViewModel = new LatestRunInfoModel();
myViewModel.LastRunDate = company.xxxx.BLL.Helpers.GetLastRunInfo();
return View(myViewModel);
}
View and the attempt to display variable value:
<td><label id="lblfdhdr">File Destination: </label>@Html.LabelFor(m => Model.LastRunDate)</td>
Hopefully somebody can help, I feel like I am really close just need that little push.
Edit: I had to remove some personal info and stuff like that. Ignore the names of things, it's just the display code on my view that is not working. Thanks in advance!