Click here to Skip to main content
15,897,315 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All

I want to have eval funtionality in imageurl of imagebutton which is in gridview.
But it throws compile time. Can we have like this.If so what is the syntax?

XML
<asp:ImageButton ID="imgActivate" runat="server" ImageUrl='<%#DataBinder.Eval(Container.DataItem, "picturename")?"/Images/Active.PNG":"/Images/InActive.PNG" %>'
                                            OnClick="imgActivate_Click"  OnCommand="imgActivate_Command" CommandArgument='<%# Eval("UserId") %>'
                                            CommandName="Activate"  />


Regards
froxy
Posted

No, this wont work. You cant have code blocks in server tags.
 
Share this answer
 
 
Share this answer
 
hi you can do that in the Following Way.
XML
<asp:TemplateField HeaderText="Small Image">
                                       <ItemTemplate>
                                           <asp:Image ID="imgPlacesSmallImage" ImageUrl='<%# String.Concat(@"~\Uploads\PlaceImages\SmallImage\",Eval("placetovisitimages_image")) %>' AlternateText="N.A"
                                               Width="25%" Height="15%" runat="server" />
                                       </ItemTemplate>
                                       <ItemStyle Width="30%" HorizontalAlign="Center" />
                                   </asp:TemplateField>
 
Share this answer
 
v2

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