title: JQuery Datatables and ASP.NET MVC Parameter to ActionResult
body: <p>I'm trying to return a View with a Jquery datatable, whose action is launched from a previous page with the ActionLink--</p>
  
  <pre><code>@Html.ActionLink("View Audit", "Audit", new { id= Model.ID }) 
  </code></pre>
  
  <p>The Jquery datatable is then pre-filtered with the ID passed from the Model ID.</p>
  
  <p>Here is my JS file...(incidentally, a static value e.g. 10005 works here in the fnServerParams, but I need the value to be dynamic based on whatever Model ID is chosen from theprevious screen)</p>
  
  <pre><code>var oTable = $('#myAuditTable').dataTable({
       "sAjaxSource": "GetAuditLog",
          "fnServerParams": function ( aoData )
      {            aoData.push({ "name": "ID", "value": 10005 })
       },
   "aoColumns": [
  ....
  </code></pre>
  
  <p>Here is my Audit.cshtml page.</p>
  
  <pre><code>@model IEnumerable&lt;Models.AuditLog&gt;
  
  &lt;table id="myAuditTable" width="100%"&gt;
                  &lt;tr&gt;...&lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>and in the Controller</p>
  
  <pre><code>    public ActionResult GetAuditLog(int ID){
  
          var logs = db.AuditLog.Where(c =&gt; c.ID == ID).ToList();
  
          var result = from c in logs
                       select new[] { ....
                       };
  
          return Json(new
          {
              aaData = result
          }, "text/x-json", JsonRequestBehavior.AllowGet); 
  }
  </code></pre>
  
  <p>So I normally would pass a parameter in MVC like so:</p>
  
  <pre><code>    public ActionResult Audit(int ID)
      {            
          return View(); 
      }
  </code></pre>
  
  <p>But since the GetAuditLog is the action getting results, how do I get the int ID to the GetAuditLog action in order to pass the filter the records, which in turn get passed as JSON. I can't call GetAuditLog in the ActionLink, because its job is to pull JSON, not render a View. </p>
  
  <p>I'm not sure what I'm missing. I've gone through this guy's articles cause they are pretty comprehensive as far as integrating ASP.NET and datatables.
  <a href="http://www.codeproject.com/Articles/155422/jQuery-DataTables-and-ASP-NET-MVC-Integration-Part" rel="nofollow noreferrer">http://www.codeproject.com/Articles/155422/jQuery-DataTables-and-ASP-NET-MVC-Integration-Part</a>
  But cannot find an exact fit to my problem.
  This post seems to come close...
  <a href="https://stackoverflow.com/questions/8505639/how-do-i-access-the-jquery-datatables-plugin-aodata-values-in-mvc3">How do I access the JQuery DataTables plugin aoData values in MVC3?</a>
  But doesn't quite apply since he seems to be working with a successfully passed-in parameter.</p>
  
  <p>Thanks for any help.</p>