Monday 15 February 2010

c# - Display images from local folder to datalist using Asp.net -


I am displaying images to the dentist from my application. The source code is:

  & lt; ASP: Data List ID = "DTIlist" Runat = "Server" Repeat column = "4" cellpadding = "5" & gt; & Lt; ItemTemplate & gt; ATP: Image width = "100" id = "Image 1" ImageUrl = '& lt;% # bind ("name", "~ / images / {0}")%> Runat = "server" /> & Lt; Br / & gt; & Lt; / Itememplate & gt; & Lt; Madstream border collar = "brown" border style = "dotted" borderwidth = "3px" horizontal alliance = "center" vertical align = "bottom" /> `& Lt; / Asp: DataList & gt;   

is behind the code

  secure void BindDataList () {DirectoryInfo dir = new DirectoryInfo (MapPath ("Images")); Fileinfo [] files = dirget files (); Array list list = new arrelist (); Foreign currency (File Info Info files) {listItems.Add (info); } Dtlist.DataSource = listItems; Dtlist.DataBind (); } Secure Zero btnsave_Click (Object Sender, EventArgs e) {string filename = Path.GetFileName (fileupload1.PostedFile.FileName); Fileupload1.SaveAs (Server.MapPath ("Picture /" + File Name)); BindDataList (); }   

As such I want to display all the pictures from the local drive in the data list. C: \ Sales n purchases \ imagesFolder for the benefactor

Please help me anybody. thank you in advanced.

Please try with the code snippet below.

  & lt; ItemTemplate & gt; & Lt; ASP: image width = "100" id = "image 1" image URL = '& lt;% # string.format ("{1} \\ {0}", EVAL ("name"), EVAL ("directory" ))% & Gt; 'Runat = "server" /> & Lt; Br / & gt; & Lt; Asp: Label id = "lblImageSrc" runat = "server" text = '& lt;% # string.format ("{1} \\ {0}", Eval ("name"), Eval ("directory") % & Gt; '& Gt; & Lt; / Asp: Label & gt; & Lt; / ItemTemplate & gt;    

No comments:

Post a Comment