[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 982
  • Last Modified:

File Listing with Image (type), File Name, Size, Gridview

I am trying to generate a list of uploaded (attached) files to an form in ASP.NET
an example:
class object UploadFileItem
attributes:: string FileName, string FileSize, Image FileTypeImage

I have been able to generate an IList of itmes UploadFileItem
but if I use something like a GridView control, I can bind the IList, but only the string data is displayed and the Image attribute is just ignored.

The actual images are small bmp files and are assigned based on the file extension.

I am trying for the simplest code behind solution in c# so that I can populate an IList with objects, and bind the control to display the graphic, file name, date and size (basically mimicing an explorer list of files. (xls has Excel Icon, .doc Word Icon, etc)..

I've run across a lot of topics on Google, but none seem address a file listing.

I have tried changing the attribute for TypeImage to string, and setting an image url path based on this,  but still can not find a way to bind into the grid.

I'm new to c# and asp.net, so for all I know I'm using an inappropriate control.
  • 3
1 Solution
do you have a template column to show the image and if yes, can you post the code for the template column ,..

is this what you are trying to do .. just that the datasource you have is a custom object and not dataset ..

sdnoyesAuthor Commented:
This looks like just what I needed.  Once I adapt and test I will accept  the solution and award points.
originally I was binding to an array of objects, but this is a pretty clear explanation of creating a Data Table, and should be easily adaptable.

I will let you know the result later today.
sdnoyesAuthor Commented:
This worked.  I had to modify a bit for my purposes:
Since I have several GridViews, and will populate them with fetched info I modified to set the datasource and bind programatically:
gvImageList.DataSource = GetFileList();
  //Page.DataBind(); old Binding.

You were a lot of help.
sdnoyesAuthor Commented:
Thanks again.
I never ran across this iin any of my Google searches.
Usually I run into more garbage than answers to .net questions using Google.

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now