tags:

views:

41

answers:

1

My form is as follows, how can I retrieve the values in my controller:

<% using (Html.BeginForm("Create","Employee"))

{%> <%= Html.ValidationSummary()%>

<p><label for = "Name" >Name</label>

 <%= Html.TextBoxFor(model => model.EmployeeName)%>
 <%= Html.ValidationMessageFor(model => model.EmployeeName)%>

</p>
        <label for = "ProName">Project</label>

          <table id="projectTable">
        <tr> <td> <label for="Name" id = 1>UT1</label></td></tr>
 <tr> <td> <label for="Name" id= 2>UT2</label></td></tr>

    </table>


      <input type ="submit"  value="Save" id="submit" />

 <% }%>


public class Customer()

{ public string EmployeeName{get;set;}

public Customer()

{ projects = new List<Projects>(); }

}

pubic class Projects() { public int id{get;set;} }

A: 

You can use multiple ways to retrieve the data. I suggest you look at the NerdDiner tutorial. They provide a good clear tutorial on how do handle CRUD in MVC The chapter you want to look in is this one. http://nerddinnerbook.s3.amazonaws.com/Part5.htm

OhBugger
I have seen Nerd dinner tutorial. I`m confused because this time along with a textbox i`m having a table. I would preferusing a binding to list. Let`s say we have classes as follows in the edted part of the code.
you can always retrieve the values with a formcollection or by using Request.Form
OhBugger
the values will be dynamically created, formcollection doesn`t remain the best option in this case I suppose?
if the names of the fields are the same as in your object you can put an object in the parameter of the post action. That way the values are automatically set in the object and that way you can easily use them in the rest of your function.
OhBugger