How Can I Get Data From Selected Row?
How Can I Get Data From Selected Row?
ismailbars
Posts: 4Questions: 3Answers: 0
Hi,
I am new to DataTables and I am trying to discover the details of that issue.I have a table that ı am getting the data's of the tables rows from database.I can list the datas in row with using DataTables but I want to get datas from selected row when i click on the row and use that datas for editing,deleting,etc.
I have added my code snippet below my message.How can i do that?Can you help me please?
MY CODE
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>AdminLogin</title>
<!-- Bootstrap -->
<link href="Content/bootstrap.min.css" rel="stylesheet"/>
<link href="Content/dataTables.bootstrap.min.css" rel="stylesheet"/>
<link href="Content/jquery.dataTables.min.css" rel="stylesheet" />
<link href="Content/select.dataTables.min.css" rel="stylesheet" />
</head>
<body>
<p><br/></p>
<form id="form1" runat="server">
<div class="container">
<div class="jumbotron">
<h5>Hello <asp:Label ID="lblUser" runat="server" ForeColor="Red"/> </h5>
<h5><asp:LinkButton ID="btnLogOut" runat="server" ForeColor="Red" CssClass="pull-right" OnClick="btnLogOut_Click"
Font-Underline="True">Log Out</asp:LinkButton> </h5>
<h1>Kullanıcılar</h1>
</div>
<h1>User List</h1>
<asp:Repeater ID="rptUsers" runat="server">
<HeaderTemplate>
<table class="table table-striped table-bordered table-hover" id="UserList">
<thead>
<tr>
<th>User Name</th>
<th>IsAdmin</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label ID="lblUserName" runat="server" Text='<%# Eval("UserName~~~~") %>' />
</td>
<td>
<asp:Label ID="lblAdmin" runat="server" Text='<%# Eval("IsAdmin") %>' />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody> </table>
</FooterTemplate>
</asp:Repeater>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="scripts/jquery-1.12.4.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="scripts/bootstrap.min.js"></script>
<script src="scripts/jquery.dataTables.min.js"></script>
<script src="scripts/dataTables.bootstrap.min.js"></script>
<script src="scripts/dataTables.select.min.js"></script>
<script>
$(document).ready(function () {
$('#UserList').DataTable({
"aLengthMenu": [[4, 8, 12, -1], [4, 8, 12, "All"]],
"iDisplayLength": 4,
select: {
style: 'single'
}
});
});
</script>
</form>
</body>
</html>
This discussion has been closed.
Answers
Does this example help?
https://datatables.net/extensions/select/examples/api/get.html
Kevin
hi @rf1234 ,i use your code but when i want to get "bla"s value,i get "undefined" alert message.
I don't see your java script field definitions in your code. You need to have those with a field "yourField" to make the code work. Just take a look at the examples please.
Thank you. @rf1234
Worth also reading this part of the documentation which details how Select works with the API.
Allan