HierarchicalDataSourceControl Class (FileSystemDataSource example)

Discussion in 'ASP .Net' started by =?Utf-8?B?RnJhbmNpcyBSZWVk?=, Feb 28, 2006.

  1. Hi

    I'm working on creating a hierarchical data source control to represent data
    in an SQL database in a hierarchical way. To get started learning how to
    create these controls, I decided to recreate to example on the
    FileSystemDataSource.

    Step 1

    I created a class library called FileSystemDataSourceControl, and copy and
    paste the code in the file called FileSystemDataSourceLib.cs in a namespace
    called econcordia. Finally I build the Class library and produce
    FileSystemDataSourceControl.dll

    Step 2

    I create a second project called mySite. While in design mode for
    Default.aspx, I right click on the toolbar and select Choose Items... . I
    then browse to the dll file I created previously. Now I can see
    FileSystemDataSource under the general tab. I drag FileSystemDataSource to
    the designer for Default.aspx. If I Press F5 (or Start Debugging), there are
    now errors on the screen. I then drop an instance of the treeview in the
    designer for default.aspx, and bind it to FileSystemDataSource1. Then when I
    run it, I get the following error in FileSystemDataSourceLib.cs.

    return (temp.GetFileSystemInfos().Length > 0);

    An unhandled exception of type 'System.StackOverflowException' occurred in
    mscorlib.dll

    I have the feeling that the treeview is in and endless loop, constantly
    calling the GetHierarchicalView method from the FileSystemDataSource class.
    Also, if I delete the FileSystemDataSource from the designer in page
    default.aspx, and instead put the following code in the Page_Load event for
    page Default.aspx it works.

    Econcordia.FileSystemDataSourceView v = new
    Econcordia.FileSystemDataSourceView(".");

    TreeView1.DataSource = v.Select();
    TreeView1.DataBind();

    So the previous code works, but I would like it, to be able to drag and
    instance of the FileDataSource to the designer of page Defautl.aspx and get
    it to work. Could someone help me get this example working? Here's a link to
    the article. If someone can help me get this working I would really
    appreciate it
    http://msdn2.microsoft.com/en-us/library/system.web.ui.hierarchicaldatasourcecontrol.aspx
     
    =?Utf-8?B?RnJhbmNpcyBSZWVk?=, Feb 28, 2006
    #1
    1. Advertising

  2. I apologize for the types. The following line in step 2 reads as follows

    If I Press F5 (or Start Debugging), there are now errors on the screen.

    replaced it with

    If I Press F5 (or Start Debugging), there are no errors on the screen.



    "Francis Reed" wrote:

    > Hi
    >
    > I'm working on creating a hierarchical data source control to represent data
    > in an SQL database in a hierarchical way. To get started learning how to
    > create these controls, I decided to recreate to example on the
    > FileSystemDataSource.
    >
    > Step 1
    >
    > I created a class library called FileSystemDataSourceControl, and copy and
    > paste the code in the file called FileSystemDataSourceLib.cs in a namespace
    > called econcordia. Finally I build the Class library and produce
    > FileSystemDataSourceControl.dll
    >
    > Step 2
    >
    > I create a second project called mySite. While in design mode for
    > Default.aspx, I right click on the toolbar and select Choose Items... . I
    > then browse to the dll file I created previously. Now I can see
    > FileSystemDataSource under the general tab. I drag FileSystemDataSource to
    > the designer for Default.aspx. If I Press F5 (or Start Debugging), there are
    > now errors on the screen. I then drop an instance of the treeview in the
    > designer for default.aspx, and bind it to FileSystemDataSource1. Then when I
    > run it, I get the following error in FileSystemDataSourceLib.cs.
    >
    > return (temp.GetFileSystemInfos().Length > 0);
    >
    > An unhandled exception of type 'System.StackOverflowException' occurred in
    > mscorlib.dll
    >
    > I have the feeling that the treeview is in and endless loop, constantly
    > calling the GetHierarchicalView method from the FileSystemDataSource class.
    > Also, if I delete the FileSystemDataSource from the designer in page
    > default.aspx, and instead put the following code in the Page_Load event for
    > page Default.aspx it works.
    >
    > Econcordia.FileSystemDataSourceView v = new
    > Econcordia.FileSystemDataSourceView(".");
    >
    > TreeView1.DataSource = v.Select();
    > TreeView1.DataBind();
    >
    > So the previous code works, but I would like it, to be able to drag and
    > instance of the FileDataSource to the designer of page Defautl.aspx and get
    > it to work. Could someone help me get this example working? Here's a link to
    > the article. If someone can help me get this working I would really
    > appreciate it.
    > http://msdn2.microsoft.com/en-us/library/system.web.ui.hierarchicaldatasourcecontrol.aspx
     
    =?Utf-8?B?RnJhbmNpcyBSZWVk?=, Feb 28, 2006
    #2
    1. Advertising

  3. =?Utf-8?B?RnJhbmNpcyBSZWVk?=

    Fixme Guest

    I've had the same experience. I have also written my own hierarchical
    data source following the example, with similar results.

    I'm pretty confident the example is erraneous. What happens is the data
    bound control (the treeview) makes repeated calls to
    GetHierarchicalView, with different values for the viewPath parameter
    (the descendants of the root node). Since the sample returns the same
    view every time, the calls seems never to get past the first child,
    restarting every time, as it were.

    Or so I thought. But having changed the code to create and return a new
    view every time, the same error occurs. So I haven't gotten to the
    bottom of it yet.

    Good luck.



    --
    Fixme
    ------------------------------------------------------------------------
    Posted via http://www.codecomments.com
    ------------------------------------------------------------------------
     
    Fixme, Jun 1, 2006
    #3
    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. Eamon Millman
    Replies:
    2
    Views:
    4,610
    Kazarin Max
    Feb 18, 2006
  2. E11
    Replies:
    1
    Views:
    4,955
    Thomas Weidenfeller
    Oct 12, 2005
  3. Eamon Millman

    TreeView with custom HierarchicalDataSourceControl

    Eamon Millman, Feb 3, 2006, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    172
    Kazarin Max
    Feb 18, 2006
  4. Francis Reed

    HierarchicalDataSourceControl Class and System.StackOverflowExcept

    Francis Reed, Feb 28, 2006, in forum: ASP .Net Building Controls
    Replies:
    4
    Views:
    166
    Joey Chömpff
    Apr 3, 2006
  5. Sam Roberts
    Replies:
    15
    Views:
    321
    Sam Roberts
    Feb 7, 2005
Loading...

Share This Page