c# - How to get edited value in MVC -


im new in mvc 1.

in project im assigning ilist model , using forloop im assigning textbox , dropdox etc... user can change value per there requirement. want, how value present on aspx page in form of ilist when user click on save button present @ top of page.

here code im using populating form....

<asp:content id="content1" contentplaceholderid="maincontent" runat="server">                        <% using (html.beginform("mycontroller", "editcopyrestaurantmealrate", formmethod.post, new { id = "frmeditcopyrestaurantmealrate" })) { %>  <%= html.submit("save services", applicationpermissions.managecontract, new { name = "submitbutton" })%>  <table width="100%" class="edit_restaurant_form"> <col width="19%" /> <col width="30%" /> <col width="19%" /> <col width="*" />   foreach (var item in model)     {        %> <tr>          <th>             <label for="datefrom">                 effective from:</label>&nbsp;<label class="mandatory">*&nbsp;</label>         </th>         <td>             <% string dtfrom = "";                 dtfrom = item.datefrom.tostring("dd-mmm-yyyy");             %>             <%= html.textbox("datefrom", dtfrom)%>         </td>         <th>             <label for="dateto">                 effective to:</label>&nbsp;<label class="mandatory">*&nbsp;</label>         </th>         <td>             <% string dtto = "";                dtto = item.dateto.tostring("dd-mmm-yyyy");             %>             <%= html.textbox("dateto", dtto)%>         </td>     </tr> <%  }       %> 

here controller code.

public actionresult mycontroller(string submitbutton, ilist<cms.model.vcmsrestaurant> addendummealrates) {     // need receiv value in list edited      return view(@"~\index.aspx", addendummealrates); } 

how the value in mycontroller user edited on page?

you create method in controller, catch postback.

if it's simple data can like:

public actionresult editrestaurant(string datefrom, string dateto) {     // values here. } 

or create viewmodel, can encapsulate more complex data:

public actionresult editrestaurant(editrestaurantviewmodel editrestaurantvm) {     // values here. } 

as can see trying postback list of items, in table, i'll add answer:

as far know, can't post structure of data back, either need use javascript library knockout.js, or use raw javascript/jquery gather data, , send ajax.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -