How to Display Images in DataList Control using ASP.Net 2.0
Download Source Code : 264_ImageUpload.zip
In this article I will try to explain you the technique of displaying images in DataListControl using ASP.Net 2.0.
Often developing a Web Application you need to provide facility to your visitors to upload file or images on your site. For example, you are developing a web application like community sites and you want to allow user to upload their photos in their profiles. To perform this kind of task you need know how file upload system works in ASP.Net 2.0 and how you can display images on the browser using image control.
Here in this article I will show you the technique of handling this kind of situations. All you need to do is, place three controls on your browser that are FileUpload, Button, DataList Control. Code for your web form will be look like:
In DataList control notice that I have use the Image control that further uses the Eval function. This function evaluates an expression and returns the result. Here it will return the full path of the file. Now lets see how the code behind work in the success of this application. First add the code in Page_load event: