是否可以在该文件夹的gridview中显示文件? [英] Is it possible to display the files in gridview from the folder?

查看:69
本文介绍了是否可以在该文件夹的gridview中显示文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



是否可以从文件夹在gridview中显示文件?不是从数据库中显示文件.如果可以,请告诉我如何做?

谢谢,

Hi,

Is it possible to display the files in gridview from the folder?Not from the database.If yes,kindly tell me how?

Thanks,

推荐答案



是的,您可以在数据控件中显示文件名

在这里,我提供一些代码来读取目录中的文件列表

Hi,

yeah you can display file names in data control

Here I''m providing some code for reading list of files in directory

<asp:DataList ID="DataList1" runat="server" onitemcommand="DataList1_ItemCommand" Width ="60%"
       >
     <HeaderTemplate >
       <table width="100%" align="center">
         <tr>
           <td>List of Items</td>
         </tr>

     </HeaderTemplate>
     <itemtemplate>
          <tr>
           <td>

               <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl ="~/Default13.aspx"  > <%#Container.DataItem %>

           </td>
         </tr>
     </itemtemplate>
     <footertemplate>
         </footertemplate></table>



文件后面的代码包含以下代码



And code behind file contains following code

            DirectoryInfo dinfo = new DirectoryInfo(Server.MapPath ("~/Scripts"));
            FileInfo[] finfo = dinfo.GetFiles();
            List<string> str = new List<string>();
            foreach (var g in finfo)
            {
                str.Add(g.FullName);
            }
          
          
           

            DataList1.DataSource = str;
            DataList1.DataBind();

</string></string>



在上面的代码中,它显示了脚本文件夹中现有的所有文件

希望您能理解我说的话

最好的



In the above code it displays all the files existing in scripts folder

I hope you understood what I said

All the Best


引用显示文件文件夹目录GridView


这篇关于是否可以在该文件夹的gridview中显示文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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