Databinding to a list of files in DirectoryInfo

G

Guest

I keep getting an error that my listbox control is incompatible with the
source as follows:

The base class includes the field 'IMGList', but its type
(System.IO.DirectoryInfo) is not compatible with the type of control
(System.Web.UI.WebControls.ListBox).

the following is the codebehind:
public class EventBroadcast : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Table EBroadcast;
protected System.Web.UI.WebControls.LinkButton ImageAttach;
protected System.IO.DirectoryInfo ImgList;
protected System.Web.UI.WebControls.ListBox IMGList;

public string stringpath
{
get{return Server.MapPath(@"..\BroadcastIMG\");}
}
private void Page_Load(object sender, System.EventArgs e)

ImageAttach.Attributes.Add("onClick","javascript:window.open('../Secured/EmailIMG.aspx','imgWindow','width=700, height=275');");
GetDirPath(stringpath);
}
public void GetDirPath(string Path)
{
ImgList=new DirectoryInfo(Path);
FileInfo[] files=ImgList.GetFiles();
foreach(FileInfo file in files)
{
IMGList.Items.Add("Name");
}
}

what am I missing here? How to make the DirectoryInfo compatible with a
listbox?

Sam-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top