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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:15:29+00:00 2026-06-01T20:15:29+00:00

I have a datatable, on that datatable i set a Html.ActionLink. When I click

  • 0

I have a datatable, on that datatable i set a Html.ActionLink. When I click that action link, I want to send an id of the item to a javascript function and have a new datatable appear below with all of its content that belongs to the selected item in the datatable above. So for example if I click a students name in a table, I want all the students Grades and Test to appear below in a separate datatable. I’ve never worked with javascript much so I’m not sure how I can do this. If someone can please point me in the right direction or give some tips I’d appreciate it.

original first datatable:

@foreach (var item in ((List<Epic>) ViewData["selectedestimate"]))
{
    <tr>
        <td>
            @*   @Html.ActionLink(@item.Name, "action", "controller", new {id = item})*@

            <a href="#" onclick="StoryClick(@item.Id);">@item.Name</a>
        </td>   

Javascript to call:

<script type="text/javascript">
function StoryClick(story) {
    $.get("@Url.Action("action", "controller")", function (response) {
        $('#stories').accordion({ collapsible: true });
    });
}
</script>

ActionController:

public List<EpicDetails> getEpicDetails(int id)
{
    return eRepository.getItemsById(id).tolist();
}

Or do I need an ActionResult?

public Actionresult Details(int id)
{

}

I realize that I’m not even close right now, but its just b/c I’m not sure what steps to take to do this.
Eventually I would make a accordion and put the table in the accordion.

  • 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-01T20:15:30+00:00Added an answer on June 1, 2026 at 8:15 pm

    In situations like this I like to actually keep the <a> the ActionLink generates, and just add JavaScript to enhance the behavior of the link. So your view wouldn’t really change (I did add a class so that we can bind an event handler to it later):

    @Html.ActionLink(@item.Name, "action", "controller", new {id = item, @class = "item-link" })
    

    Then write some jQuery (it looks like you already have a dependency on jQuery. If not, I can revise the answer to use vanilla JavaScript) to bind an event handler to links with class item-link:

    <script type="text/javascript">
        $(document).ready(function () {
            $("a.item-link").click(function (event) {
                event.preventDefault(); // Stop the browser from redirecting as it normally would
                $.get(this.href, function (response) {
                    // Do whatever you want with the data.
                });
            });
        });
    </script>
    

    And, yes, your action method in the controller should return an ActionResult. It’s hard for me to say what type of ActionResult you should return without actually knowing what type of data you want to consume on the client, but if you wanted to inject HTML onto the page, you could write something like this:

    public ActionResult Details(int id)
    {
        var itemDetails = /* Get details about the item */;
        return PartialView("Details", itemDetails);
    }
    

    Then in your JavaScript you would write:

    $("a.item-link").click(function (event) {
        event.preventDefault(); // Stop the browser from redirecting as it normally would
        $.get(this.href, function (response) {
            $("element_to_populate").html(response);
        });
    });
    

    Where element_to_populate would be a selector that points to where you want to inject the HTML.

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

Sidebar

Related Questions

I have a dataTable that lists some objects and I want to set a
I have a datatable that uses the cell editor function. In each row, I
Ok. So I am pretty new a this. I have a datatable that I
I have a h:dataTable that displays ProfileNotification like below: <h:dataTable value=#{myBean.profileNotifications} var=item rendered=#{myBean.renderProfileNotification}> <h:column>
I have a DataTable that contain 3000 records.I want to do the replication between
I have a Devexpress.XtraGrid.GridControl that I have set the DataSource to a DataTable .
I have a DataTable that queries out something like below usergroupid...userid......username 1.............1...........John 1.............2...........Lisa 2.............3...........Nathan
I have a DataTable that has a boolean column called [Invalid]. I need to
I have a DataTable that I manually created and loaded with data using C#.
I have a datatable that contains rows of transaction data for multiple users. Each

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.