从文件夹名称为Asp.net的Diff文件夹将图像加载到DataList图像模板 [英] Load Image To DataList Image template from Diff Folder With Folder Name Asp.net

查看:70
本文介绍了从文件夹名称为Asp.net的Diff文件夹将图像加载到DataList图像模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,

我面临一个问题.

请帮忙.

我正在做一个ASP.Net项目.在这个项目中,我想显示特定路径上的图像.我已经做到了.

问题是我无法根据文件夹排列图像.

我的意思是在一个文件夹中有三个文件夹.这三个文件夹包含更多图像.我想查看以文件夹名称作为标题的图像.

Guys,

I am facing a problem.

Please help.

I am doing a ASP.Net Project. In this project I want to show the images on a particular path. That I have done.

The problem is I can''t arrange the image on the basis of folder.

I mean inside one folder are three folders. Those three folders contain more images. I want to see the image with folder name as header.

Is it possible?

推荐答案



我为您的要求做了一些代码检查一次

Hi,

I did some code for your requirement check this once

<div id="maincontent" runat="server">

     </div>



在html代码中置于标签上方,然后文件后面的代码包含以下代码



place above tag in html code then code behind file contains following code

public void filldata()
 {

     DirectoryInfo dinfo = new DirectoryInfo(Server.MapPath("~/Images"));
     DirectoryInfo[] subdinfo = dinfo.GetDirectories();


     StringBuilder sb = new StringBuilder();
     foreach (DirectoryInfo di in subdinfo)
     {
         FileInfo[] finfo = di.GetFiles();
         sb.Append("<table width="\"100%\""><tr><td colspan="\""+finfo.Length">"+di.Name +"</td></tr></table>");

         sb.Append("<tr>");
         foreach (FileInfo fino in finfo)
         {
             sb.Append("<td><img src="\""" di.name="" fino.name="" width="\"100\"" height="\"100\"" alt="\"NoImage\"" /><td>");

         }
         sb.Append("</td></td></tr><br />");


     }

     maincontent.InnerHtml = sb.ToString();
 }



在pageload事件中调用上述方法

在这里,在我的示例中,我具有三个子文件夹的
尝试此操作,可以显示任意数量的文件夹名称为标题的子文件夹图像

最好的



call above method in pageload event

And Here In my example I ''ve Images folder with three subfolders

Try this you can display any number of subfolder images with folder name as heading

All the Best


这篇关于从文件夹名称为Asp.net的Diff文件夹将图像加载到DataList图像模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆