Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
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
XML
<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
VB
<asp:ImageButton ID="imgbtnView" runat="server" ImageUrl="images/add.png"
        onclick="imgbtnView_Click"/>


code behind
C#
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.NET
<asp:FileUpload ID="upBrandImages" runat="server" />
Posted
Updated 10-Mar-13 0:18am
v4

thanx pallavi

But it is displaying all the images in the folder
i want to display the selected one only
help me
 
Share this answer
 
Comments
Mohamed Mitwalli 10-Mar-13 6:20am    
This is not an answer if you want to add Comment or Question Go for Have a Question or Comment?
sarvanik 10-Mar-13 6:23am    
thanx pallavi

But it is displaying all the images in the folder
i want to display the selected one only
help me
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[^]
 
Share this answer
 
Comments
sarvanik 10-Mar-13 6:24am    
thanx pallavi

But it is displaying all the images in the folder
i want to display the selected one only
help me
Pallavi Waikar 10-Mar-13 6:50am    
sorry for late reply i am bessy in other task..u have to mix this article with this article http://www.aspdotnet-suresh.com/2011/12/jquery-lightbox-image-slideshow-gallary.html...means use code for load images of first article...and append in second article to disply images...hope u can manage it..he has giving anchor tag to images
Pallavi Waikar 10-Mar-13 7:20am    
if u want to show only one image then why r using datalist ....
u can simply add one image control and after saving that image only set ImageUrl of image control i.e upBrandImages.SaveAs(Server.MapPath("~//UploadedFiles//" + filename)); Image2.ImageUrl="~//UploadedFiles//" + filename;
sarvanik 10-Mar-13 7:31am    
thanx pallavi
but when we take image control,if i select one image and later another one i have to display these two images ,it is not possible in image control then how to get it help me
Pallavi Waikar 10-Mar-13 7:37am    
ok then use both image control and datalist...newly added image automaticaly displayed in imge box...and all other images will displayed by binding datalist to folder simpal i.e
upBrandImages.SaveAs(Server.MapPath("~//UploadedFiles//" + filename));Image2.ImageUrl="~//UploadedFiles//" + filename;
BindDataList();

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900