HTML Code:
JQuery Code:
var $table = $("#dgdProduct"),
$headerCells = $table.find("thead th"),
$rows = $table.find("tbody tr");
var rows = [];
var isChecked;
var pcode;
var pDescription;
$rows.each(function(row, v) {
var $td = $(this).closest('tr').children('td');
$td.find("input:checkbox").each(function() {
isChecked = $(this).attr('checked');
});
if ($td.length > 0) {
if (isChecked == true) {
pcode= $td.find('input:hidden[id$=hdID]').val();
pDescription=$td.eq(1).text() ;
}
}
});
<asp:DataGrid ID="dgdProduct"
runat="server" >
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox
ID="chkP" runat="server" />
<input
id="hdID" type="hidden" value='<%#
Eval("pCode") %>' />
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn
DataField="pDescription" HeaderText="Product
Description">
</asp:BoundColumn>
<asp:BoundColumn
DataField="Quantity" HeaderText="Quantity">
</asp:BoundColumn>
</Columns>
</asp:DataGrid>
JQuery Code:
var $table = $("#dgdProduct"),
$headerCells = $table.find("thead th"),
$rows = $table.find("tbody tr");
var rows = [];
var isChecked;
var pcode;
var pDescription;
$rows.each(function(row, v) {
var $td = $(this).closest('tr').children('td');
$td.find("input:checkbox").each(function() {
isChecked = $(this).attr('checked');
});
if ($td.length > 0) {
if (isChecked == true) {
pcode= $td.find('input:hidden[id$=hdID]').val();
pDescription=$td.eq(1).text() ;
}
}
});
This comment has been removed by the author.
ReplyDeleteThank you vaia..
Delete