I'm pretty sure it's easy but I can't seem to find it.
我很确定这很容易,但我似乎无法找到它。
I have 2 table linked together in sql;
我在sql中有2个表链接在一起;
table1 with field named idTable1, info
table2 with field named idTable1, idTable2, moreInfo
when I show the view that can add a new row into table2, I have access to idTable1
当我显示可以向table2添加新行的视图时,我可以访问idTable1
<%=Html.Encode(Model.idTable1)%>
but when I submit for form, I'm losing that information, in the controller the IdTable1 is now empty
但是当我提交表单时,我正在丢失该信息,在控制器中IdTable1现在是空的
how to fix that "problem" ?
如何解决这个“问题”?
thanks!
1 个解决方案
#1
Instead of using Html.Encode
, you might try using Html.Hidden
. Example:
您可以尝试使用Html.Hidden,而不是使用Html.Encode。例:
<form>
...
<%= Html.Hidden("idTable1", Model.idTable1) %>
...
</form>
This will submit the value for idTable1
along with the form data.
这将提交idTable1的值以及表单数据。
#1
Instead of using Html.Encode
, you might try using Html.Hidden
. Example:
您可以尝试使用Html.Hidden,而不是使用Html.Encode。例:
<form>
...
<%= Html.Hidden("idTable1", Model.idTable1) %>
...
</form>
This will submit the value for idTable1
along with the form data.
这将提交idTable1的值以及表单数据。