Repeart Select Whole Line Operation Instance in asp.net
- 2021-06-28 09:05:14
- OfStack
This paper describes an example of how Repeart in asp.net selects an entire row.Share it for your reference.
The implementation is as follows:
<asp:Repeater runat="server" ID="rpt_Student">
<HeaderTemplate>
<table>
<tr id="tr_<%#this.rpt_Student.Items.Count%>" onclick='Tr_Click(tr_<%#this.rpt_Student.Item.Count%>)'>
<td> Full name </td>
<td> School Number </td>
<td> achievement </td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr >
<td><%#Eval("Sname")%></td>
<td><%#Eval("SID")%></td>
<td><%#Eval("Sscore")%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
The jq code is as follows:
<script type="text/javascript">>
function Tr_Click(id) {
if ($("#" + id).attr("style") == "background:red") {
$("#" + id).attr("style", "background:white");
} else {
$("#" + id).attr("style", "background:red");
}
}
</script>
I hope that the description in this paper will be helpful to everyone's asp.net program design.