public DropDownList FileList(string FolderName,string FileType)
{
DropDownList List = new DropDownList();
try
{
DirectoryInfo dirinfo = new DirectoryInfo(FolderName);
FileInfo[] myfolders = dirinfo.GetFiles(FileType);
foreach (FileInfo myfolder in myfolders)
{
List.Items.Add(myfolder.Name);
}
}
catch{}
return List;
}
DropDownList3=FileList(mapPath,"*.htm");???????????????、
这个DropDownList3是手工建的怎么才能让它等于FileList()的返回值。
现在这么直接=没有值
{
DropDownList List = new DropDownList();
try
{
DirectoryInfo dirinfo = new DirectoryInfo(FolderName);
FileInfo[] myfolders = dirinfo.GetFiles(FileType);
foreach (FileInfo myfolder in myfolders)
{
List.Items.Add(myfolder.Name);
}
}
catch{}
return List;
}
DropDownList3=FileList(mapPath,"*.htm");???????????????、
这个DropDownList3是手工建的怎么才能让它等于FileList()的返回值。
现在这么直接=没有值
{
try
{
DirectoryInfo dirinfo = new DirectoryInfo(FolderName);
FileInfo[] myfolders = dirinfo.GetFiles(FileType);
foreach (FileInfo myfolder in myfolders)
{
dl.Items.Add(myfolder.Name);
}
}
catch{}
}
FileList(DropDownList3, mapPath, "*.htm");
但是修改一下
public void FileList(ref DropDownList dl, string FolderName,string FileType)
{..}
FileList(ref DropDownList3, mapPath, "*.htm");
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/csref/html/vclrfRef.htm
其实DropDownList本身是个引用类型不加ref也可以的。