Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6158481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:57:50+00:00 2026-05-23T20:57:50+00:00

I am trying to use jquery DataTables plugin to display details from my db

  • 0

I am trying to use jquery DataTables plugin to display details from my db table, and use the Jeditable to allow user edit each cell inline. The edited data should be post back and save in database. I came across an example which is quite similar to my scenario here: http://naspinski.net/post/Inline-AJAX-DropDown-and-Text-Editing-with-AspNet-MVC-and-jQuery.aspx and i tried to implement following that as a guide.

However, I face some problem here:

  1. When and how should I use Url.Content() and what should be passed in and returned??

  2. I get an error when trying to edit the table cell: [MissingMethodException]: No parameterless constructor defined for this object.

I knew I did something very wrong here but I just not able to clear my doubt.
Here is the script i used to make my cell editable:

$(function () {

    // Initialize a data table
    var myTable = $('#example').dataTable({
        // To use themeroller theme
        "bJQueryUI": true
    });

    // Make every cell editable
    $('td', myTable.fnGetNodes()).editable('@(Url.Action("Edit", "Home"))',
    {
        indicator: 'saving...',
        tooltip: 'click to edit...',
        style: 'inherit',
        placeholder: 'click to edit'
    });
});

And the controller action i used to save the edited data into db:

[HttpPost]
    public void Edit(HttpContext context)
    {
        string elementId = context.Request.Form["id"];
        string fieldToEdit = elementId.Substring(0, 4);

        //now take anything after those 4 and it is the Id:
        int idToEdit = Convert.ToInt32(elementId.Remove(0, 4));

        // the value is simply a string:
        string newValue = context.Request.Form["value"].Trim();

        var food = dbEntities.Foods.Single(i => i.FoodID == idToEdit);

        switch (fieldToEdit)
        {
            case "name": food.FoodName = newValue; break;
            case "amnt": food.FoodAmount = Convert.ToInt32(newValue); break;
            case "sdat": food.StorageDate = Convert.ToDateTime(newValue); break;
            case "edat": food.ExpiryDate = Convert.ToDateTime(newValue); break;
            case "type": food.FoodTypeID = Convert.ToInt32(newValue); break;
            case "cont": food.ContainerID = Convert.ToInt32(newValue); break;
            default: throw new Exception("invalid fieldToEdit passed");

        }
        dbEntities.SaveChanges();


        context.Response.Write(newValue); 
    }

Really need some help here… Appreciate it…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:57:52+00:00Added an answer on May 23, 2026 at 8:57 pm

    First Question:

    Url.Content() should be used for serving static files ie JS or CSS like

    Url.Content("~/Scripts/jquery.js")
    

    It will return a direct URL to this static file. Starting with a ~ will ensure, the usage of the correct base dir (i.e. if you are running you application in a virtual directory).

    2nd Question:

    Your action method has to return an ActionResult to be identified as an action. It can be parameter less, because you have access to the HttpContext as a property of your controller class.

    [HttpPost]
    public ActionResult Edit()
    {
        string elementId = this.HttpContext.Request.Form["id"]; 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.