将文件夹中的所有图像绑定到gridview [英] bind all images from folder to gridview

查看:105
本文介绍了将文件夹中的所有图像绑定到gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好先生.
我有一个包含50张图片的文件夹.我在下面有一个gridview代码

hello sir.
i have a folder that had 50 images. i have a gridview code is below

<asp:GridView ID="GV" runat="server" AutoGenerateColumns ="false" >

                        <Columns >
                            <asp:BoundField HeaderText ="ID" DataField ="id"/>
                            <asp:TemplateField HeaderText ="IMAGE">
                                <ItemTemplate>

                                    <asp:Image ID="Img" runat="server" ImageUrl="image" Width="50" Height="50"/> <br />
                                    <asp:Button ID="BtnAdd" runat="server" Text="Add To Cart"  CommandName="add" CommandArgument ='<%#Eval("id") %>' />
                                    <asp:Button ID="btnremove" runat="server" Text="Remove From Cart"   CommandName="remove"  />

                                </ItemTemplate>
                            </asp:TemplateField>

                        </Columns>
                    </asp:GridView>
    </div>




在业务逻辑中,我给出了存储过程的名称,sp是

创建proc procname
首先开始
从表名中选择ID,图像
结束

id是图像的ID,而image是图像的路径.我想使用此路径绑定文件夹中的所有图像.
我如何在page_load事件中绑定我写的




in the business logic i give the storedprocedure name, the sp is

create proc procname
as begin
select id, image from tablename
end

id is id of the image, and image is path of the image. i want to bind all of the images from folder using this path.
how can i bind in the page_load event i write

protected void Page_Load(object sender, EventArgs e)
    {
        DataSet ds = new DataSet();
        ds = BusinessLogic.DisplayImage();
        GV.DataSource = ds;
        GV.DataBind();

    }



请任何人帮助我.

谢谢.



plz any body help me.

thanking you.

推荐答案

首先,
更改此行:
GV.DataSource = ds;



GV.DataSource = ds.Tables[0];

之后,您需要将datagrid中的ImageURL字段映射到数据表中的image字段,以便可以从此处进行选择.

看看 [ [^ ].
Firstly,
Change this line:
GV.DataSource = ds;

to

GV.DataSource = ds.Tables[0];

After this, you need to map the ImageURL field in datagrid to the image field in your datatable such that it can be picked from there.

Have a look at this[^] and this[^].




看看下面的URL.

http://thirumalaipm.blogspot.com/2011/02/binding- images-to-gridview-from-folder.html [ ^ ]
Hi,

Have a look at the following url.

http://thirumalaipm.blogspot.com/2011/02/binding-images-to-gridview-from-folder.html[^]


这篇关于将文件夹中的所有图像绑定到gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆