Click here to Skip to main content
15,892,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my code from this code i wanna bind link button and i need to do perform action for the link button
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

$(document).ready(function () {

//GetDetails();
$.ajax({

type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
url: "JSON.aspx/LoadData",
data: "{}",
success: function (response) {
BindTable(response.d);
},
failure: function (data) {
alert('error');
}
});

});



function BindTable(sam) {

var div = document.getElementById('divTbl');
try {

var tbl = document.getElementById('newtable');
if (tbl.id != null) {
div.removeChild(tbl);
}

}
catch (e) {

}

var tab = document.createElement('table');
tab.setAttribute('id', 'newtable');
tab.setAttribute('cellpadding', '0');
tab.setAttribute('cellspacing', '0');
tab.setAttribute('width', '100%');

var body = document.createElement('tbody');
var trow, cell;
var i;

$.each(sam, function (index, emp) {

trow = document.createElement("tr");

for (i = 0; i < 4; i++) {

cell = document.createElement('td');
cell.setAttribute('width', '200px');

var id = emp.Id;
var name = emp.Name;
var code = emp.Code;
var add = emp.Address;
var email = emp.Email;

if (i == 0) {

var hfd = document.createElement('input');
hfd.setAttribute('type', 'hidden');
hfd.setAttribute('id', 'hfd_' + id);
hfd.setAttribute('value', id);
cell.setAttribute("width", "200px")
cell.appendChild(hfd);
cell.appendChild(document.createTextNode(name));

}

else if (i == 1) {

cell.setAttribute("width", "200px");
cell.appendChild(document.createTextNode(code));
}

else if (i == 2) {

var span = document.createElement('span');
cell.setAttribute("width", "200px");
span.setAttribute("display", "inline-block");
span.appendChild(document.createTextNode(email));
cell.appendChild(span);

}

else if (i == 3) {
cell.setAttribute("width", "200px");
cell.appendChild(document.createTextNode(add));
}

trow.appendChild(cell);
}
body.appendChild(trow);

});

tab.appendChild(body);
div.appendChild(tab);

}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900