1

Please i need help in converting the image url property of an image control written in C# to its equivalent in vb.net. I am following a tutorial which i got from this site on how to display images on a gridview using base64 this is the url of the tutorial. http://dotnetawesome.blogspot.in/2013/10/how-to-insert-image-into-database-and.html. The tutorial was written in C# please i need the equivalent of this in vb.net

<ItemTemplate>
    <asp:Image ID="Image1" runat="server" Width="100px" ImageUrl='<%#Eval("Picture").ToString() == ""?"": GetImageString64((byte[])Eval("Picture")) %>' />
</ItemTemplate>

1 Answer 1

1

Use If Operator

<ItemTemplate>
    <asp:Image ID="Image1" runat="server" Width="100px" ImageUrl='<%# If(Eval("Picture").ToString() = "", "", GetImageString64(CType(Eval("Picture"), Byte()))) %>' />
</ItemTemplate>

Here's how it works:

If( argument1, argument2, argument3 )

the above syntax will evaluate argument1. If argument1 is true, it will return argument2, otherwise it will return argument3.

In your case argument1 is Eval("Picture").ToString() = "", argument2 is "", and argument3 is GetImageString64(CType(Eval("Picture"), Byte())).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.