Click here to Skip to main content
15,916,835 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hello,
I have access database which have hyperlink column, and values as "/yes.bmp", "/no.bmp".
Then in asp.net have a GridView with ImageField which in browser will show Yes image, or No image. ImageField Properties >> DataImageUrlFormatString: ~/images/{0}.jpg.
My goal is to get in vb.net code a value from GridView's imagefield.
For example, if GridViews.rows(x).cells(x).ImageField(0).value is "Yes.bmp" then ....
This example I have wrote just as expression, for better understanding.
I know how to get GridViews text values, or data values, but for Images I have never done it.

Thank you in advance for help to anyone.
Posted
Comments
Sandeep Mewara 6-May-11 0:21am    
It's ok. There is always the first time. Try out.

Thank you for help, and tips. I have found a solution.

Here is an aspx code for Gridview field:
XML
<asp:TemplateField>
            <ItemTemplate>
                <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("jan1", "~{0}.bmp") %>' />
            </ItemTemplate>
        </asp:TemplateField>


And, vb.net code:
VB
Dim img As Image = CType(GridView1.Rows(0).FindControl("image1"), Image)
        TextBox1.Text = img.ImageUrl
 
Share this answer
 
/* Your Need to contact Your Image Location Folder path to Image Name retrieve from the DataBase in the f0llowing way. */

<asp:Image ID="ImageButton2" ImageUrl='<%# String.Concat("Image/", Eval("ProductImage")) %>' Width="50%" Height="30%" runat="server" />
 
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