I'm working on a control that binds folder directories to a DropDownList in
the control. When I enable caching, each item in the DropDownList appears
2x. If I don't enable caching, the control loads w/o any issues.


<%@ Control Language="C#" TargetSchema="
http://schemas.microsoft.com/intellisense/ie5"; %>
<%@ OutputCache Duration="600" VaryByParam="none" VaryByControl="ddlFolders"
%>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.IO" %>

<script runat="server">

    private string _FolderLocation;
    private List<string> listFolders = new List<string>();

    public string FolderLocation
    {
      get{return _FolderLocation;}
      set{_FolderLocation = value;}
    }

    private void Page_Load(object sender, EventArgs e)
    {
      ddlPopulateFolders(ddlFolders);
    }

    private void ddlPopulateFolders(DropDownList ddl)
    {
      LoadFolders();

      foreach (string str in listFolders)
      {
            ddl.Items.Add(new ListItem("/" + str, "/" + str));
      }
    }

    private void LoadFolders()
    {
            if (_FolderLocation != null)
            {
                DirectoryInfo dir = new DirectoryInfo(_FolderLocation);

                foreach (DirectoryInfo g in dir.GetDirectories())
                {
                    listFolders.Add(g.Name);
                }
            }
    }

</script>

<asp:DropDownList ID="ddlFolders" runat="server" />


--
Thank you,
Ryan Olshan
     Rolog - http://blogs.dirteam.com/blogs/ryan/


[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/KIlPFB/vlQLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to