如何在C#中将中继器中的两个应用程序文件夹图像与图像和缩略图图像绑定 [英] how to bind two application folder images in repeater with image and thumbnail image in c#
问题描述
请有人告诉我如何一次在转发器控件中显示图像文件夹和缩略图文件夹中的图像.
我只能从文件夹中读取一个文件夹图像,但无法在ASP,NET C#的同一中继器控件中读取或显示第二个文件夹图像
Pls someone tell that how to show images from image folder and thumbnail folder in repeater control at a time.
i am able to read only one folder images from folder but i am not able to read or show second folder image in same repeater control in asp,net c#
Private Sub LoadDataList()
'Dim imagesFolder As String = MapPath("PostedImages")
Dim imagesFolder As String = MapPath("upload\PopupImage")
'Dim imagesFolder1 As String = MapPath("upload\ThumbImage")
Dim objDI As New DirectoryInfo(imagesFolder)
'Dim objDI1 As New DirectoryInfo(imagesFolder1)
dlImages.DataSource = objDI.GetFiles()
dlImages.DataBind()
End Sub
并在中继器控制中
and in repeater control
<img src=''<%# Eval("FullName") %>'' style="border:1px solid gray;" />--%>
请某人帮助一次显示两个应用程序文件夹中的图像
谢谢
Pls someone help to show images from two application folder at a time
Thanks
推荐答案
它说C#是一种语言,但对我来说却像VB.
无论如何,这是在VB中
It says C# as a language, but that looks like VB to me.
Anyways, here it is in VB
Dim imagesFolder As String = MapPath("upload\PopupImage")
Dim thumbFolder As String = MapPath("upload\ThumbImage")
'Create a List of type FileInfo and initialise it
Dim listOfFileInfo As List(Of FileInfo) = New List(Of FileInfo)
'Add each FileInfo from the Directory to the List
For Each f In New DirectoryInfo(imagesFolder).GetFiles
listOfFileInfo.Add(f)
Next
'Add each FileInfo from the other directory to the List
For Each f In New DirectoryInfo(thumbFolder).GetFiles
listOfFileInfo.Add(f)
Next
'Set it as the DataSource
ListBox1.DataSource = listOfFileInfo
以防万一,您确实需要在C#中使用它
Just in case you do need it in C#
string imagesFolder = MapPath("upload\\PopupImage");
string thumbFolder = MapPath("upload\\ThumbImage");
//Create a List of type FileInfo and initialise it
List<FileInfo> listOfFileInfo = new List<FileInfo>();
//Add each FileInfo from the Directory to the List
foreach (FileInfo f in new DirectoryInfo(imagesFolder).GetFiles())
{
listOfFileInfo.Add(f);
}
//Add each FileInfo from the other directory to the List
foreach (FileInfo f in new DirectoryInfo(thumbFolder).GetFiles())
{
listOfFileInfo.Add(f);
}
//Set it as the DataSource
ListBox1.DataSource = listOfFileInfo;
我使用了一个列表框将项目添加到其中,但是我确信它可以与您进行数据绑定的任何对象一起使用.
希望对您有帮助
I used a listbox to add the items to, but I am sure it will work with what ever you are databinding.
Hope this helps you
这篇关于如何在C#中将中继器中的两个应用程序文件夹图像与图像和缩略图图像绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!