Binding a dictionary to a relay using a tag

<asp:Repeater ID="rptAlbum" runat="server"> <ItemTemplate> <a runat="server" href="<%# DataBinder.Eval("key")) %>" rel='lightbox[<%#Eval("value") %>]'> <asp:Image ID="Image1" runat="server" ImageUrl='<%#Eval("key") %>' Width="30px" Height="30px"/> </a> </ItemTemplate> </asp:Repeater> 

I try many ways to catch the dictionary key in my href, but always give me the answer that the server tag is not formed or the string does not have the key property ..: s

If someone can help me, it will be very helpful :)

Best wishes

+4
source share
2 answers

Your outer quotes where not so:

  <asp:Repeater ID="rptAlbum" runat="server"> <ItemTemplate> <a runat="server" href='<%# DataBinder.Eval("key")) %>' rel='lightbox[<%#Eval("value") %>]'> <asp:Image ID="Image1" runat="server" ImageUrl='<%#Eval("key") %>' Width="30px" Height="30px"/> </a> </ItemTemplate> </asp:Repeater> 
+2
source

you cannot use this: with a with a runat server. it cannot contain another yellow code (only in its internal text)

  <a href="<%# DataBinder.Eval("key")) %>" rel='lightbox[<%#Eval("value") %>]'> <asp:Image ID="Image1" runat="server" ImageUrl='<%#Eval("key") %>' Width="30px" Height="30px"/> </a> 

important:

this is great :

  <a runat="server " > <%# DataBinder.Eval("lalala")) %> </a> 

this is wrong

 <a runat="server " something='<%# DataBinder.Eval("lalala")) %>' > //here is the error - it contains a yellow code inside the runat server DECLARATION of the element <%# DataBinder.Eval("lalala")) %> </a> 
0
source

All Articles