Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey there, here is my code and i'll explain my issue below it. 

<pre lang="HTML">   <ItemTemplate>...<input class="hideelement toggle" id="<%#Eval("ID") %>" type="checkbox" checked="checked"><label class="lblscanImg"  for="<%#Eval("ID") %> "> view scan</label>... </ItemTemplate>


I would like to link the label to input. the problem is the 'label's' id is the same for all the rows.?! when i select any label in the grid view, only the first element in the first row is affected. i inspected code behind and all the labels have the same id. I'm trying to make the id's unique so that when i select any random label in the grid, only within the selected labels row would its element change.
there is also no post back. so in conclusion: in what way can i change the id, that it would be unique for all rows.

I hope you understand. appreciate the help.

What I have tried:

i have tried to make the selection static, i have tried to but java script as the id, i no idea what to do.
Posted
Updated 22-Feb-18 2:24am
v2

1 solution

You can use the ItemIndex to get a unique number per row

<input id="<%#Container.ItemIndex.ToString() %>" ... 
 
Share this answer
 
Comments
helpwithmycode 23-Feb-18 3:30am    
Hey there thanks so much. i found that ItemIndex wasn't recognised but i changed it to 'DataItemIndex' and it workes. :) yay!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900