且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将选定的图像从文件上传绑定到datalist

更新时间:2022-10-21 10:40:49

使用System.IO检索图像名称并将该集合对象绑定到datalist。

通过以下链接。

http://www.aspdotnet-suresh。 com / 2011/05 / how-to-bind-images-from-folder-to.html [ ^ ]


thanx pallavi



但它显示文件夹中的所有图像

i只想显示所选的一个

帮帮我

Hi every one
I am trying that when user click image button which is out side datalist , i want to display selected image in a data list which is stored in a folder(solution explorer)
please Help me
Thanx in Advances

my code

<asp:DataList ID="dlBrands" runat="server" onitemcommand="dlBrands_ItemCommand">
    <ItemTemplate>
        <asp:Image ID="imgBrandImages" runat="server" Height="100px" Width="200px" ImageUrl='<%#Bind("Name","~//UploadedFiles/{0}") %>' />
    </ItemTemplate>
</asp:DataList>




my image button

<asp:ImageButton ID="imgbtnView" runat="server" ImageUrl="images/add.png"
        onclick="imgbtnView_Click"/>



code behind

string filename = Path.GetFileName(upBrandImages.PostedFile.FileName);
    if (filename !="")
    {
        upBrandImages.SaveAs(Server.MapPath("~//UploadedFiles//" + filename));
        BindDataList();
    }
    else
    {
      Response.Write("Please Select Image");

    }


file upload

<asp:FileUpload ID="upBrandImages" runat="server" />

Retrieve images name using System.IO and bind that collection object to datalist .
go through following link.
http://www.aspdotnet-suresh.com/2011/05/how-to-bind-images-from-folder-to.html[^]


thanx pallavi

But it is displaying all the images in the folder
i want to display the selected one only
help me