How to set a control ID in ListView Template dynamically?
- by citronas
A have a ListView that is rendered with multiple items.
Now I want to toggle some HTML attributes with JQuery. Therefore it would be best to have access to these elements via an unique ID.
But trying to create a "dynamic" and therefore unique ID by
<tr runat="server" ID='<%# this.GetUniqueID() %>'>
</tr>
results in an error that tells me that the ID needs to be simple and cannot be set by a call to a method.
I know that I can dynamically create controls in the code-behind and set the ID there. But in this case, I'd rather like to let the content be rendered by the ListView itself.
That brings me to the conclusion that the idea of setting a dynically ID in the Template is totally wrong. How can I achieve the desired behaviour?