0
我是一名新開發人員,我遇到了一個問題,我想爲網絡中的用戶輸入指定一個現有整數(在域中)。我該怎麼做呢?以下是我的應用解決方案中的代碼。如何將int值從web輸入傳遞到C#asp.net-mvc 3中的域int?
當前的錯誤信息:不能隱式轉換類型 '詮釋' 到 'AppDomain.MainFrame.Entities'
模型片段:(WebFrame.cs)
namespace AppWeb.Models
{ 公共類WebFrame { ... public int Urgency {get;設置;} ... }}
位指示片段:(WebFrameController.cs) - 在我需要幫助。我嘗試了一些不同的東西,但都導致了相同的錯誤。
namespace AppWeb.Controllers
{
public class WebFrameController : Controller
{
...
[HttpPost]
public ActionResult Index(HttpPostedFileBase FileIn, WebFrame webFrameWork)
{
...
if (webFrame.Urgency != 0)
{
//>>> *** THIS IS WHERE I NEED HELP, I'VE TRIED A FEW THINGS TO NO AVAIL, INCLUDING HARDCODING NEEDDONEINDAYS =1*** <<<
//TODO:Assign Urgency from MVC Web App user input to Need Done In Days Value (= NeedDoneInDays) in Domain
Entities NeedDoneInDays = new Entities();
NeedDoneInDays = webFrame.Urgency;
//NeedDoneInDays = 1;
//NeedDoneInDays = Urgency;
}
.... does some processing to get to Log if necessary.
}
...
}
}
具有接受緊急度值的函數的頁面。
AppDomain.MainFrame.Entities.Reporting.cs。
namespace AppDomain.MainFrame.Entities
{
public class Reporting
{
public static void LogToMainLogAndProcess(System.Web.HttpRequest hReq, System.DateTime StartTime, string projectType, int NeedDoneInDays)
{
//does some processing... logging and storing...
}
public static void LogAndReport(System.Web.HttpRequest hReq, string Department, System.DateTime StartTime, string projectType, int NeedDoneInDays)
{
//does some processing... logging and storing...
}
}
}
在此先感謝您的幫助!
不,緊急性是一個int,我想表示int NeedDoneInDays。這怎麼能做到?我可能會採取錯誤的方法,因爲通過類型/對象有點混亂。但我的目標是將分配給int Urgency的值設置爲int NeedDoneInDays。謝謝您的幫助。 – user864675
問題已解決。該函數在另一個頁面中被調用,並且我能夠成功地將該值傳遞給該頁面。謝謝您的幫助! – user864675