tags:

views:

29

answers:

1

I'm pretty sure it's easy but I can't seem to find it.

I have 2 table linked together in sql;

   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

 <%=Html.Encode(Model.idTable1)%>

but when I submit for form, I'm losing that information, in the controller the IdTable1 is now empty

how to fix that "problem" ?

thanks!

+1  A: 

Instead of using Html.Encode, you might try using Html.Hidden. Example:

<form>
...
<%= Html.Hidden("idTable1", Model.idTable1) %>
...
</form>

This will submit the value for idTable1 along with the form data.

Johnny G