I have an asp.net listview:
<asp:ListView ID="MyListView" runat="server" GroupItemCount="3" >
<LayoutTemplate>
<table>
<tr>
<td>
<table border="0" cellpadding="0">
<asp:PlaceHolder runat="server" ID="groupPlaceHolder"></asp:PlaceHolder>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
<GroupTemplate>
<tr>
<asp:PlaceHolder runat="server" ID="itemPlaceHolder"></asp:PlaceHolder>
</tr>
</GroupTemplate>
<ItemTemplate>
<td>
<input class="Status-Checkbox" id="StatusCheckBox" runat="server"
type="checkbox" value=<%#Eval("StatusId")%> />
</td>
</ItemTemplate>
</asp:ListView>
In jquery, i have:
var MyStatId=MyStatId
The problem i that when the page is rendered the checkboxes have dynamic id.
So i have to filter the checkbox by
class=Status-Checkbox
and value, something like:
$('.Status-Checkbox').find(value=MyStatId)
Who has already done something like that?
This should work.
When dealing with the dynamic ID thing. I prefer to add a custom attribute rather than relying on the ID. It does make finding items much much easier. If, for example you used your PK name of (“fieldName”) as the attribute you could easily find it with:
)
which IMO makes it clearer what you’re looking for (should anyone else ever have to work on your code).