Reputation: 832
My repeater is as below
<ItemTemplate>
<tr>
<td class="ms-vb2">
<a href="#" id="aTitle" runat="server" onclick='<%# DataBinder.Eval(Container.DataItem,"ColumnLink") %>'>
<%# DataBinder.Eval(Container.DataItem,"FieldName") %></a>
</td>
<td class="ms-vb2">
<asp:Label Text='<%# DataBinder.Eval(Container.DataItem,"ControlType") %>' runat="server"
ID="lblType" />
</td>
<td class="ms-vb2" colspan="2">
<asp:Image ID="imgChecked" runat="server" ImageUrl="/_layouts/images/check.gif" AlternateText='<%# DataBinder.Eval(Container.DataItem,"IsRequired") %>' />
</td>
<td class="ms-vb2" colspan="2">
<asp:CheckBox ID="chkGroupUnique" Checked="false" runat="server" AutoPostBack="true"
OnCheckedChanged="chkGroupUnique_CheckChanged" /><%--OnCheckedChanged="chkGroupUnique_CheckChanged"Checked='<%# Boolean.Parse(DataBinder.Eval(Container.DataItem,"Approved").ToString()) %>'--%>
</td>
</tr>
One of the dataitem is a checkbox, upon clicking this checkbox I can get the id of the checkbox as well as the data that I want (lblType) because I added those things in the ItemDataBound event like below
CheckBox chk = (CheckBox)e.Item.FindControl("chkGroupUnique");
Label lblType = (Label)e.Item.FindControl("lblType");
chk.Attributes.Add("onclick", "Check(this,'" + chk.ClientID + "','" + lblType.ClientID + "');");
The onclick function contains this code
function Check(checkbox, chkBoxId, typeId) {
var chk = document.getElementById(chkBoxId);
var type = document.getElementById(typeId);
if (checkbox.checked) {
var t = type.innerText;
}
return false;
}
Now that I have both the checked checkbox clientId and the label clientId. I want to check if there is any other checkbox that is checked and have the same value in that row label control. How do I do that using jQuery or plain javascript
Thanks in advance
Upvotes: 0
Views: 1744
Reputation: 2325
I would suggest you to Add each CheckBox Control into Control Collection in ItemDataBound Event.(You Can also form Collection Of their IDs)
Pass that collection to Javascript Function and in Javascript function Iterate through it to check the Status of Checkboxes..
Upvotes: 0