HierarchicalDataSourceControl Class (FileSystemDataSource example)

G

Guest

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
 
G

Guest

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.
 
F

Fixme

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.
 

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,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top