Posts

Showing posts with the label webgrid

How to post a WebGrid to a Controller using Ajax

Image
Clash Royale CLAN TAG #URR8PPP How to post a WebGrid to a Controller using Ajax I want to post the full WebGrid from my view to my controller using ajax. In this WebGrid I display a table from a database and I want to provide, that the user of this webpage can update the columns (in the database). WebGrid WebGrid My try so far: public JsonResult UpdateTable(GridView model) { // Update Model to db.. string message = "Success"; return Json(message, JsonRequestBehavior.AllowGet); } The GridView model here has always 0 columns. GridView model WebGrid <div id="tableGridDiv"> @grid.GetHtml( tableStyle: "table", columns: cols) </div> Script $('.save-user').on('click', function () { var grid = $("#tableGridDiv").find("table.grid").first(); alert(grid.innerHTML); var jsonGrid = JSON.stringify(grid); //var jsonGrid = $.parseJSON(grid); alert(jsonGrid); $.ajax({ ur...