I have a dropdownlist that I have in an EditItemTemplate that I need to populate with a list of files in a directory on my web server.
Currently, this is how I'm retrieving the file names:
DirectoryInfo dir =
new DirectoryInfo(@"e:\web\xxx\htdocs" + strPath);FileInfo[] bmpfiles = dir.GetFiles("*.*");
foreach( FileInfo f in bmpfiles){
ddl.Items.Add(f.Name);
lblMessage.Text += "Name is: " + f.Name + "<br>";
}
From my web form I am calling this class, passing in a path (directory name), the DropDownList I want to add the items to, and then a Label to see the output for testing.
Is this the right approach Or should I build a dataset with the file names then do the DataBinding in the Control code

Need help populating a DropDownList in and EditItemTemplate
jandrews
Thanks for your attention to my question. I actually just created a datatable and stuffed the File IO data into it. It wasn't that difficult, just didn't know if there was another way since there are always a million ways to do things.
Thanks again
Eivind__no09
This actually appears to be an ASP.NET application; the question would be better asked at the ASP.NET forums (www.asp.net/forums). I am moving the post back to the data access forum, as it certainly is more relevant there than in the windows forms forum.
It depends on what your are trying to do with this list of files. Building a DataSet is probably overkill; you might try setting the DataSource of the DropDownList to the FileInfo array, and setting the DisplayMember and ValueMember to "Name".
KrishnaKumar Sivasubramanian
John Maloney