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.

I presume that the image field is 1st column in GridView.

Dim img As Image = CType(GridView1.Rows(0).Cells(0).Controls(0), Image)

if Not IsNothing(img) Then
  ... do comparison
End If

Thank you for help, and tips.
Aspx code for Gridview field.

<asp:TemplateField>
            <ItemTemplate>
                <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("jan1", "~{0}.bmp") %>' />
            </ItemTemplate>
        </asp:TemplateField>

And, Vb.net code:

Dim img As Image = CType(GridView1.Rows(0).FindControl("image1"), Image)
        TextBox1.Text = img.ImageUrl
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.