Adding Id to url from hyperlink

Adding Id to url from hyperlink

Holmes_MorHolmes_Mor Posts: 1Questions: 1Answers: 0

Hi I have the following code where i am trying to add the id which is the hyperlink to the end of my url.

    // DataTable
    var table = $('#dataTable').DataTable({
        dom: 'lBfrtip',
        buttons: [
            { extend: 'csvFlash', text: 'Download' }
        ],        
        columnDefs: [
    {
        targets: 1,
        render: function (data, type, row, meta) {
           if (type === 'display') {
               data = '<a href="@Url.Action("action", "controller")?=' + data + '">"' + data + '"</a>';
                }

                return data;
            }
        }
           ]
      });

The code above works but the ID is in a string and i need it in an int. I can't for the life of me see where i've gone wrong, i know it is an easy fix but i can't see it

Answers

  • mohamad.jalalimohamad.jalali Posts: 1Questions: 0Answers: 0
    edited June 2016

    Great

  • MOR_HOMSMOR_HOMS Posts: 3Questions: 1Answers: 0
    edited June 2016

    i Changed this line

    data = '<a href="@Url.Action("action", "controller")?=' + data + '">"' + data + '"</a>';
    

    to this

    data = '<a href="@Url.Action("action", "controller")?id=' + data + '">'+ data + '</a>';
    

    and it worked. I Knew it was something simple

This discussion has been closed.