0

In my page I have a datatable. What I want is to change the data on table by from options on tree menu which are links. Basically, each item on tree menu will trigger the Stored Procedure with different parameters.

So far I tried to send the parameter like

<a href="@Url.Action("InboxListByType", "Folder", new { DocumentTypeId = 3 })">e-TCGB</a>

But it is not working. I'm stuck so bad.

This is the ActionResult

public ActionResult InboxListByType(FormCollection coll, int DocumentTypeId)
{
    ClaimsIdentity identity = (ClaimsIdentity)User.Identity;
    int CompanyId = Convert.ToInt32(identity.FindFirst("CompanyId").Value);

    int Draw = Convert.ToInt32(coll["draw"]);
    int RowStart = Convert.ToInt32(coll["start"]);
    int RowCount = Convert.ToInt32(coll["length"]);
    int TotalRows = 0;
    DataSet ds = DocumentDB.Document_List_Inbox(CompanyId, RowStart, RowCount, DocumentTypeId, out TotalRows);

    string DatatableJson = Utility.DatatableToJson(ds.Tables[0]);

    return Content("{ \"draw\": " + Draw + ", \"recordsTotal\" :" + TotalRows + " , \"recordsFiltered\": " + TotalRows + ", \"data\": " + DatatableJson + " } ");
}

One of the problems is FormCollection coll element is coming in as null.

Can anyone help?

Nkosi
  • 235,767
  • 35
  • 427
  • 472
Ege Bayrak
  • 1,139
  • 3
  • 20
  • 49
  • 2
    Your making a GET, not a POST so `FormCollection` will always be `null`. If you want to send values for `draw`, `start` etc, then you need to add query string or route values - `new { DocumentTypeId = 3, Draw = someValue }` and add those parameters to the method –  Mar 14 '16 at 13:51
  • Would changing the ActionResult to POST work too? – Ege Bayrak Mar 14 '16 at 13:53
  • 2
    No, Because its a link (which does a redirect to a GET method), not a form. –  Mar 14 '16 at 13:53
  • You can take a look at this answer https://stackoverflow.com/questions/5409899/pass-complex-object-with-redirect-in-asp-net-mvc may it would help – Mostafiz Mar 14 '16 at 14:18
  • What are you trying to return? – DCruz22 Mar 14 '16 at 14:30
  • I'm returning table data – Ege Bayrak Mar 14 '16 at 14:31

0 Answers0