这是我的代码:
控制器:
Private Sub Workbook_Open()
Const FILENAME As String = "Export.xlsx"
Const PROMPT As String = "Press [Yes] to continue or [No] to cancel"
Dim FilePath As String, Title As String, SharedFolder As String
ToggleEvents False, False
Do
SharedFolder = getSharedFolder()
If Len(SharedFolder) = 0 Then
Title = "Folder not found"
Else
FilePath = SharedFolder & FILENAME
If Len(Dir(FilePath)) = 0 Then Title = "File not found"
End If
If Len(SharedFolder) = 0 Then
If MsgBox(PROMPT:=PROMPT, Buttons:=vbYesNo, Title:=Title) = vbYes Then
setSharedFolder
Else
Exit Sub
End If
End If
Loop Until Len(Dir(FilePath))
UpdateWorkBook FilePath
ToggleEvents True, True
End Sub
型号:
public ActionResult InsertData(CoModel coModel)
{
if (ModelState.IsValid)
{
db.Entry(coModel).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(coModel);
}
查看:
public class CoModel
{
[Key]
public int id { get; set; }
public string item_no { get; set; }
public string destination { get; set; }
public int total_piece { get; set; }
}
这是我的问题。为什么每次按下Save按钮时控制器都会收到零/零值?我的编码错了吗?
答案 0 :(得分:0)
您正在使用隐藏的DisplayFor。您必须使用EditorFor,TextBox,TextBoxFor,TextArea和其他渲染输入HTML类型不同的隐藏。