Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have images displayed using the DataList() control. Each of image displayed have their own button inside to vote the image.

Goal and problem faced:
So I am trying to get access the image button using the DataList OnItemCommand but it's not working.

What I have tried:

DataList :
ASP
<asp:DataList Width="100%" ItemStyle-horizontalalign="center" ItemStyle-Width="200px" ID="imgDataList" runat="server" RepeatColumns="3" OnItemCommand="imgDataList_ItemCommand">


Button inside DataList :
ASP
<asp:Image ID="imgFavBefore" runat="server" CssClass="voteStyle" ImageUrl="~/Img Content/love.png" Style="height: 20px; width: 20px; align-content: center;" CommandName="btnFavBefore" data-index="<%#Container.ItemIndex %>" />


VB.Net code to get access on button inside DataList :
VB
Protected Sub imgDataList_ItemCommand(source As Object, e As DataListCommandEventArgs)
  If e.CommandName = "btnFavBefore" Then
    ' some code here
  End If
End Sub
Posted

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