Note that there are some explanatory texts on larger screens.

plurals
  1. POpassing value from javascript to ajax in mvc4
    primarykey
    data
    text
    <p>i need to select a value from a grid and pass it to ajax. I'm getting the error as "Id undefined". can anyone suggest me a solution for this issue. Records most be deleted which a presented in grid. on clicking the button selected value must got to ajax function for deletion process. value s moved to ajax but getting error that the policyid is undefined Thanks in advance.</p> <p>Code of grid column:</p> <pre><code>@{ var grid = new WebGrid(Model.Policy, rowsPerPage: 20, selectionFieldName: "selectedRow", ajaxUpdateContainerId: "gridcal"); grid.Pager(WebGridPagerModes.NextPrevious);} @grid.GetHtml( tableStyle: "webgrid-table", headerStyle: "webgrid-header", footerStyle: "webgrid-footer", alternatingRowStyle: "webgrid-alternating-row", selectedRowStyle: "webgrid-selected-row", rowStyle: "webgrid-row-style", columns: grid.Columns( grid.Column("PolicyName","Policy Name",style: "colWidth"), grid.Column("PolicyValue","Policy Value",style: "colWidth"), // grid.Column ("Delete",format:@&lt;text&gt;&lt;a href="@Url.Action("DeletePolicy","Roles",new{PolicyId=item.PolicyId.ToString()})"&gt;&lt;img src="~/Images/img-delete-blk-icon.png" width="9" height="9" alt="Delete"/&gt;&lt;/a&gt; &lt;/text&gt;) ****grid.Column(format: @&lt;text&gt;&lt;input type="image" onclick="AJAXCall_Fun_DeletePolicy()" src="~/Images/img-delete-blk-icon.png" name="image" width="9" height="9" /&gt;&lt;/text&gt;)**** )) @if (grid.HasSelection) { &lt;b&gt;Policy Name&lt;/b&gt;@AppliedPolicies.PolicyName&lt;br /&gt; &lt;b&gt;Policy Value&lt;/b&gt;@AppliedPolicies.PolicyValue&lt;br /&gt; } </code></pre> <p>Ajax :</p> <pre><code> function AJAXCall_Fun_DeletePolicy() { if ($.xhrPool.length &gt; 0) { $.each($.xhrPool, function (idx, jqXHR) { if (jqXHR) { this.abort(); } }); $.xhrPool = []; } var PolicyId = PolicyId(); if (PolicyId.length &gt; 0) { $.ajax({ type: "GET", url: "/Roles/DeletePolicy", data: { 'PolicyId': JSON.stringify(PolicyId) }, async: true, cache: false, datatype: "json", </code></pre> <p>Controller code:</p> <pre><code> public JsonResult DeletePolicy(string PolicyId) { bool status = false; using (clsBLLGroups objclsBLLGroups = new clsBLLGroups()) { status = objclsBLLGroups.DeletePolicy(UserCookieWrapper.UserAccessToken, PolicyId.ToString()); } return Json(status, JsonRequestBehavior.AllowGet); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload