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 8161545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:31:19+00:00 2026-06-06T18:31:19+00:00

I have been searching for the last few hours, and unfortunately I cannot seem

  • 0

I have been searching for the last few hours, and unfortunately I cannot seem to find an example of how to populate a datatable with an action edit and delete link column using .net and MVC.

Here is what I have so far, how do I add an action link? What am I missing?

<script type="text/javascript">
$(document).ready(function () {
    $('#myDataTable').dataTable({
        bProcessing: true,
        sAjaxSource: '@Url.Action("Index1", "Default1")'
    });

});
</script>

<div id="container">
<div id="demo">
    <table id="myDataTable">
        <thead>
            <tr>
                <th>
                    RoleId
                </th>
                <th>
                    RoleName
                </th>
                <th>
                    UserId
                </th>
                <th>
                    UserName
                </th>
            </tr>
        </thead>
        <tbody> 
        </tbody>
</table>    
</div>
</div>

I want to add this in the last column;

    <td>
        @Html.ActionLink("Edit", "Edit", new {id=item.PrimaryKey}) |
        @Html.ActionLink("Details", "Details", new { id=item.PrimaryKey }) |
        @Html.ActionLink("Delete", "Delete", new { id=item.PrimaryKey })
    </td>

But cannot figure out how to do 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-06-06T18:31:20+00:00Added an answer on June 6, 2026 at 6:31 pm

    You could use the aoColumns property with fnRender function to add custom columns.
    You can’t use the Html.ActionLink helper because you have to generate the links dynamically from the javascript. The aoColumns property helps you to configure each columns, if you don’t want to configure a particular column just pass null else you have to pass an object({}).

    The fnRender function helps you to create the links using the values of the other columns. You can use the oObj.aData to get the values of the other column like id to generate the links.

    <script type="text/javascript">    
        $(document).ready(function () {
            $('#myDataTable').dataTable({
                bProcessing: true,         
                sAjaxSource: '@Url.Action("Index1", "Default1")',
                aoColumns: [
                          null, // first column (RoleId)
                          null, // second column (RoleName)  
                          null, // third (UserId)
                          null, // fourth (UserName)
    
                          {     // fifth column (Edit link)
                            "sName": "RoleId",
                            "bSearchable": false,
                            "bSortable": false,
                            "fnRender": function (oObj)                              
                            {
                                // oObj.aData[0] returns the RoleId
                                return "<a href='/Edit?id=" 
                                    + oObj.aData[0] + "'>Edit</a>";
                            }
                           },
    
                           { }, // repeat the samething for the details link
    
                           { }  // repeat the samething for the delete link as well
    
                       ]
         });  
    }); 
    </script>
    

    Another important thing in the JSON output you return from the server, for the edit column also you have to return something like 1, 2, 3 or anything.

    Reference: http://jquery-datatables-editable.googlecode.com/svn/trunk/ajax-inlinebuttons.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been searching everywhere for the last 3 hours and I couldn't find
For the last few hours I have been searching high and low for a
I have been searching through SO for the last few days and have found
I've been searching everywhere for the past few hours so this is my last
I have been searching and this problem seems simple but cannot find answer. I
I have been searching Google for that last 15 minutes trying to find Documentation
I have been searching several days for an example of how to make a
I have been searching vigorously the last week in hopes of finding a solution
Have been searching for a solution for hours. My entire WordPress theme validates, except
I've been searching and testing for a solution the last 3 hours now. I

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.