I am fetching data from database after returning this value binding it in view with html table i want to use jquery datatable instead of html table, link given https://datatables.net/examples/data_sources/ajax.html with checkbox also added but not getting idea how to apply it to value coming from database through view.
controller
public ActionResult Ipcell()
{
List<Ipcell> result = new List<Ipcell>();
try
{
conn.Open();
string qry = "querygiven";
OracleCommand command = new OracleCommand(qry, conn);
// command.Parameters.Add(":uug_id_users", Session[CommonConstants.SESSION_USER_ID]);
OracleDataReader reader = command.ExecuteReader();
while (reader != null && reader.Read())
{
Ipcell member = new Ipcell();
member.CaseId = reader[0].ToString();
member.Descripton = reader[1].ToString();
member.NoOfBill = Convert.ToInt32(reader[2].ToString());
member.TotalAmount = Convert.ToDecimal(reader[3].ToString());
member.Status = reader[4].ToString();
member.CreatedOn =Convert.ToDateTime(reader[5].ToString());
member.ClosedOn= Convert.ToDateTime(reader[6].ToString());
result.Add(member);
}
return View(result);
}
view
@model IEnumerable<Smart_M.Models.Ipcell>
<table id="ipcelltbl" class="table" Cssclass="gvv table table-striped table-bordered">
<thead>
<tr>
<th>Raise Bill</th>
<th>Close Bill</th>
<th>Case ID</th>
<th>Description</th>
<th>No of Bills</th>
<th>Total Amount</th>
<th>Status</th>
<th>Created On</th>
<th>Closed On</th>
</tr>
</thead>
<tbody>
@foreach (var d in Model)
{
var hid = "hide" + Convert.ToString(d.CaseId);
<tr class="">
<td><input type="button" name="rbrbill" value="Raise Bill" class="btnrowvalue1" /> </td>
<td><input type="checkbox" id="@hid" class="Chkb" name="Chkb" /></td>
<td><input type="text" value="@d.CaseId" class="CaseId" name="CaseId" /></td>
<td><input type="text" value="@d.Descripton" class="Desc" name="Desc" /></td>
<td><input type="text" value="@d.NoOfBill" class="NBill" name="NBill" /></td>
<td><input type="text" value="@d.TotalAmount" class="TAmnt" name="TAmnt" /></td>
<td><input type="text" value="@d.Status" class="Stat" name="Stat" /></td>
<td><input type="text" value="@d.CreatedOn" class="Cron" name="Cron" /></td>
<td><input type="text" value="@d.ClosedOn" class="Clon" name="Clon"/></td>
<td><input type="button" style="margin-left:2%;" value="Close Case" class="btnrowvalue2" /></td>
</tr>
}
</tbody>
</table>
Layout.cshtml applied as per jquery datatable
<script type="text/javascript">
$(document).ready(function () {
$('#ipcelltbl').DataTable();
</script>