I'm new to MVC and I'm facing problems in the selected index of the table in AJAX posts.
I have the following classes
public class contractModel {get public long hotel IDs; Set; } Receive public long passcode {ID; Set; } Public String RateCode {get; Set; } The name of the public string hotel {get; Set; } Public listing & lt; Rate band & gt; Rate band {receive; Set; }} Public class ratbandmodel {public long id {get; Set; } Apply Public DateModel to {apply; Set; } Public dateband model booklet {Receive; Set; } Type the public string type {get; Set; } Public long RoomTypeId {get; Set; }}
and here is my partial view
@model Packages.Website.Models.ContractModel @using (Ajax.BeginForm ("SelectRateBand" "Agreement" ", New Ajax option () {UpdateTargetId =" product-table "})) {& lt; Input type = "hidden" id = "rowId" name = "row iid" /> & Lt; Table border = "0" width = "100%" cellpadding = "0" cellspacing = "0" id = "product-table" & gt; & Lt; TR & gt; & Lt; Th class = "table-header-repeat line-left" & gt; & Lt; A href = "" & gt; Type of room & lt; / A & gt; & Lt; / Th & gt; & Lt; Th class = "table-header-repeat line-left" & gt; & Lt; A href = "" & gt; Board support & lt; / A & gt; & Lt; / Th & gt; & Lt; Th class = "table-haider-repeat row-left" & gt; & Lt; A href = "" & gt; By date & lt; / A & gt; & Lt; / Th & gt; & Lt; Th class = "table-header-repeat line-left" & gt; & Lt; A href = "" & gt; To date & lt; / A & gt; & Lt; / Th & gt; & Lt; Th class = "table-header-repeat line-left" & gt; & Lt; A href = "" & gt; From the book & lt; / A & gt; & Lt; / Th & gt; & Lt; Th class = "table-haider-repeat row-left" & gt; & Lt; A href = "" & gt; Book & lt; / A & gt; & Lt; / Th & gt; & Lt; Th class = "table-header-option-line-left" & gt; & Lt; A href = "" & gt; Options & lt; / A & gt; & Lt; / Th & gt; & Lt; / TR & gt; @ Html.HiddenFor (modelItem => Model.HotelId) @ Html.HiddenFor (modelItem => Model.RateCodeId) @ Html.HiddenFor (modelItem = & gt; Model.RateBands) @foreach (In Model.RateBands Item) {& LT; TR & gt; & Lt; TD & gt; @ Html.HiddenFor (modelItem = & gt; item.Id) @ Html.DisplayFor (modelItem => item.type type) & lt; / Td> & Lt; Td> @ Html.DisplayFor (model item = & gt; items. Bard bases) & lt; / Td> & Lt; Td> @ Html.DisplayFor (ModelEystem => Item.Applational.Format) & lt; / Td> & Lt; Td> @ Html.DisplayFor (model item = & gt; Item. Applicable to ToDate) & lt; / Td> & Lt; Td> @ Html.DisplayFor (ModelEystem => Item Book. Foramate) & lt; / Td> & Lt; Td> @ Html.DisplayFor (Model item = & gt; Items. Bookable toDate) & lt; / Td> & Lt; Td square = "option-width" & gt; & Lt; Input type = "submit" name = "command" class = "form-submit" /> & Lt; / TD & gt; & Lt; / TR & gt; } & Lt; / Table & gt; }
In the administrator
[HttpPost] public ActionResult SelectRateBand (ContractModel contract) {// some code here}
< P> Now I get the contract in the controller. I have no ideas on date bads and I have no idea how to help me get the selected index
If you are after the ID of the selected row, you can pass it as a root value with your AppLink Helper. . I use the name parameter to express more purpose
@ Html.ActionLink (LinkText: "edit", actionName: "SelectRateBand", controllerName: "YourController", routeValues: new { Id = Item.Id}, html content: new {@class = "icon-1 info-tooltip", @Title = "edit"});
And in your controller, an id change the action to accept the id parameter mail sent from ActionLink.
[HttpPost] public ActionResult SelectRateBand (string id) {// some code here}
Comments
Post a Comment