Windows.Forms listbox vs WebControls listbox

Discussion in 'ASP .Net' started by GentOfTheLake@gmail.com, Dec 5, 2006.

  1. Guest

    Why won't the webcontrols version of the listbox work with this:

    DirectoryInfo di = new DirectoryInfo([somepath]);
    FileInfo [] fi = di.GetFiles();
    ListBox lb = new ListBox();
    lb.AddRange(fi);

    The forms version of the listbox handles this just fine.

    Does anyone know how to convert the FileInfo[] to ListItem[] for the
    AddRange function?

    I've tried:

    ListItem[] li = new ListItem[fi.Length];
    fi.CopyTo(li,0);
    lstFiles.Items.AddRange(li);

    Compiles but I get an exception at runtime
    "Source array type cannot be assigned to destination array type."

    Thanks in advance for your help
    , Dec 5, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?bWc=?=

    ListBox (WebControls)

    =?Utf-8?B?bWc=?=, Feb 9, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,284
    dm_dal
    Feb 9, 2004
  2. Richard
    Replies:
    6
    Views:
    636
    Richard
    Jun 13, 2004
  3. Eric
    Replies:
    2
    Views:
    463
  4. mg

    ListBox (WebControls)

    mg, Feb 9, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    101
  5. JamesBrady

    WebControls, IE and Windows Forms

    JamesBrady, Apr 30, 2004, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    83
    James Brady
    May 3, 2004
Loading...

Share This Page