Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

How to pass Id to delegate using jquery .button control is added on run time in table row (tr)

$
0
0

Hi,

I have developed web api on C# (web method public static) to call using json

Work Scenario:

I have some input controls to fill data and save , as user save record its showed into repeater control.

Repeater control having edit and delete button ..

as new record insert so I get  record from list (web method ) and show into repeater.

Problem:

as I insert new Tr in table that delete and edit button needs id to pass it to delete to delete and edit specific record

I have successful method like response.d[0].id...

like this


    function OnSuccessInsert(response) {

 $('#tbluser tbody').prepend('<tr id=tr_' + NewID_ + '> <td>  <b>' + response.d[0].UserName + '  </b> </td> <td>  <b>' + usertype_ + '  </b> </td > <td>  <b>' + response.d[0].EmailID + ' </b> </td>  <td>  <b>' + userflag_ + '  </b> </td>     <td>  <input type="button" name="Edit" class="btneditcss"  id="'btnedit" value="Edit" /> </td>  <td>  <input type="button" name="Delete" class="btndeletecss" id="'btndelete'"value="Delete"  /> </td>   </tr > ');

}

…. for this I have made delegate event... I need ID to send it to deletenews method...because this tr is added on run time , so I 

created delegate to fired its onclick event....()

    $(document).ready(function () {
        $("#tbluser").delegate(".btndeletecss", "click", function () {
            deletenews(id);
        });
    });

I need ID which is in "response.d[0].ID " need to pass  it...

on normal cases we can do like this (on design time )

  <input type="button" name="Edit" id="btnedit" value="Edit" onclick="setui_edit(<%# Eval("ID") %>);" />

any help plz

My UI like this



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>