0

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.

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by dejanc
0

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
0

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

Edited by dejanc: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.