i have bind the repeater using jquery:
<table
id="tblvh">
<tr>
<th>id</th>
<th>No</th>
<th>Time</th>
<th>Action</th>
</tr>
<asp:Repeater ID="gvd" runat="server">
<ItemTemplate>
<tr>
<td>
<asp:Label ID="Label1" CssClass="id" Text='<%# Eval("id") %>' runat="server" />
</td>
<td>
<asp:Label ID="Label2" CssClass="no" Text='<%# Eval("no") %>' runat="server" />
</td>
<td>
<asp:Label ID="Label3" CssClass="time" Text='<%# Eval("time") %>' runat="server" />
</td>
<td>
<asp:CheckBox runat="server" CssClass="status" ID="chk" Checked='<%# (Eval("status")).ToString() == "1" ? true : false %>' />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
Now for the above repeater i have bind data using jquery:
<script type="text/javascript">
function BindRepeater() {
$("[id*=tblvh]").find("tr:gt(1)").remove();
$.ajax({
type: "POST",
url: "http://ift.tt/2dJQ77Y",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
},
error: function (response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
$("[id*=tblvh]").attr("border", "1");
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
var customers = xml.find("Table");
var row = $("[id*=tblvh] tr:last-child").clone(false);
$("[id*=tblvh] tr:last-child").remove();
$.each(customers, function () {
var customer = $(this);
$(".id", row).html($(this).find("id").text());
$(".no", row).html($(this).find("no").text());
$(".time", row).html($(this).find("time").text());
$(".status", row).html($(this).find("status").prop('checked', true));
$("[id*=tblvh]").append(row);
row = $("[id*=tblvh] tr:last-child").clone(true);
});
}
</script>
Now i can successfully bind the repeater with all the labels. but i am not able to checked/unchecked checkbox with their value.
in status i am getting 0 and 1 value . if 0 then unchecked and 1 then checked.
But instead of the checkbox i am getting value 0 and 1.
See the above image . i am getting 1 and 0 value instead of checkbox checked/unchecked.
How can i checked checked box if status value is 1 and unchecked if status value is 0?
Aucun commentaire:
Enregistrer un commentaire