- i want edit and delete in data table
- i have another html registration page and c# webservice for inserting the data
- when i click on edit it should be redirect to registration page and edit functionality shold be completed
<body style="font-family:'Times New Roman', Times, serif">
<form id="form2" runat="server">
<div style="padding:5px;padding-left:0px">
<a class="ShowHideColumn" data-columnindex="0">ID</a>
</div>
<div style="border:1px solid black;padding:3px;width:1200px;">
<table id="Datatable">
<thead>
<tr>
<th>ID</th>
<th>firstname</th>
<th>lastname</th>
<th>Email</th>
<th>password</th>
<th>confirmpassword</th>
<th>address</th>
<th>gender</th>
<th>qualification</th>
<th>Action</th>
</tr>
</thead>
<tfoot>
<tr>
<th>ID</th>
<th>firstname</th>
<th>lastname</th>
<th>Email</th>
<th>password</th>
<th>confirmpassword</th>
<th>address</th>
<th>gender</th>
<th>qualification</th>
<th>Action</th>
</tr>
</tfoot>
</table>
</div>
</form>
</body>
</html>
<link rel="stylesheet" type="text/css" href="DataTables-1.10.16/css/jquery.dataTables.min.css" />
<script src="DataTables-1.10.16/js/jquery.dataTables.min.js"></script>
<title>Data Table</title>
<script type="text/javascript">
$(function () {
$.ajax({
url: 'WebService2.asmx/GetAllEmployeeINFOees',
method: 'post',
dataType: 'json',
success: function (data) {
var datatableInstance = $('#Datatable').DataTable({
data: data,
columns: [
{ 'data': 'ID' },
{ 'data': 'firstname' },
{ 'data': 'lastname' },
{ 'data': 'username' },
{ 'data': 'password' },
{ 'data': 'confirmpassword' },
{ 'data': 'adrress' },
{ 'data': 'gender' },
{ 'data': 'qualication' },
],
});
$('.showHideColumn').on('click', function (e) {
e.preventDefault();
var tablecolumn = datatableInstance.column($(this).attr('data-columnindex'));
tablecolumn.visible = (!tablecolumn.visible());
});
}
});
});
</script>
public void GetAllEmployeeINFOees()
{
List<EmployeeINFO> listEmployeeINFOees = new List<EmployeeINFO>();
String connectionstring = @"Data source=DESKTOP-91DAPD2\SQLEXPRESS; Initial Catalog=Databasefirstdb;user id=sa;password=123456;";
using (SqlConnection connection = new SqlConnection(connectionstring))
{
SqlCommand cmd = new SqlCommand("spGetEmployees", connection);
cmd.CommandType = CommandType.StoredProcedure;
connection.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
EmployeeINFO employee = new EmployeeINFO();
employee.ID = Convert.ToInt32(rdr["ID"]);
employee.firstname = rdr["firstname"].ToString();
employee.lastname = rdr["lastname"].ToString();
employee.username = rdr["username"].ToString();
employee.password = rdr["password"].ToString();
employee.confirmpassword = rdr["confirmpassword"].ToString();
employee.adrress = rdr["adrress"].ToString();
employee.gender = rdr["gender"].ToString();
employee.qualication = rdr["qualication"].ToString();
listEmployeeINFOees.Add(employee);
}
}
JavaScriptSerializer js = new JavaScriptSerializer();
Context.Response.Write(js.Serialize(listEmployeeINFOees));
}