本文介绍了如何在vb.net中获取GridView的imagefield值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我有访问数据库,其中具有超链接列,值分别为"/yes.bmp"、/no.bmp".
然后在asp.net中有一个带有ImageField的GridView,它在浏览器中将显示是"图像或否"图像. ImageField属性>> DataImageUrlFormatString:〜/images/{0} .jpg.
我的目标是从GridView的imagefield中获取vb.net代码的值.
例如,如果GridViews.rows(x).cells(x).ImageField(0).value为"Yes.bmp",则....
为了更好的理解,我将此示例作为表达式编写.
我知道如何获取GridViews文本值或数据值,但是对于图像我从未做到过.

预先感谢您对任何人的帮助.

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.

推荐答案

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



而且,vb.net代码:



And, vb.net code:

<pre lang="vb">Dim img As Image = CType(GridView1.Rows(0).FindControl("image1"), Image)<br />
        TextBox1.Text = img.ImageUrl</pre><br />


/* 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" />


这篇关于如何在vb.net中获取GridView的imagefield值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 01:59