Nevermind. Problem is solved.
Rumen Stankov"]That was a good one :) If you can share the solution it would be great.
Sure. My problem was that I was trying to display something like this:
A
Alberts, Bob
Anderson, Fred
but I was getting this instead
In the data relation section below I was originally using the EmployeeID as the Parent and Child Columns, but what I needed to do was use the Letter:
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
DefaultImage="ig_treeOfficeFolder.gif" HilieClass="" HoverClass=""
DefaultSelectedImage="ig_treeOfficeFolder.gif" >
<DataBindings>
<ignav:NodeBinding DataMember="DataSource1_DefaultView" TextField="Letter" />
<ignav:NodeBinding DataMember="DataSource2_DefaultView" TextField="Name" />
</DataBindings>
<Images>
<DefaultImage Url="ig_treeOfficeFolder.gif" />
<SelectedImage Url="ig_treeOfficeFolder.gif" />
<ExpandImage Url="ig_treePlus.gif" />
<CollapseImage Url="ig_treeMinus.gif" />
</Images>
<NodeStyle>
<Padding Bottom="2px" Left="2px" Right="2px" Top="2px" />
</NodeStyle>
<SelectedNodeStyle BackColor="#316AC5" ForeColor="White">
</SelectedNodeStyle>
</ignav:UltraWebTree>
</div>
<whds:WebHierarchicalDataSource ID="WebHierarchicalDataSource1" runat="server">
<DataRelations>
<whds:DataRelation ChildColumns="Letter"
ChildDataViewID="DataSource2_DefaultView"
ParentColumns="Letter"
</DataRelations>
<DataViews>
<whds:DataView ID="DataSource1_DefaultView" DataMember="DefaultView" />
<whds:DataView ID="DataSource2_DefaultView" DataMember="DefaultView" />
</DataViews>
</whds:WebHierarchicalDataSource>
</body>
Then in the code behind, instead of selecting the employeeid, I just needed to select the Letter instead:
{
// open database connection
strConnection =
System.Configuration.ConfigurationManager.ConnectionStrings["CorporateConnectionString"].ConnectionString;
sqlConn.Open();
// Retrieve data from database with sql query.
// Use a forward-only datareader because forward only processing is all that is required.
// Create a new datatable and load it with contents in datareader.
// Finally set the datasource of the dataview to the datatable.
// Repeat for second dataview
strSQL1 = "select distinct left(Last_Name,1) as Letter from corporate..person_tbl order by 1";
//drSQL1.Read(); When reading here, the A's are skipped
dt1.Load(drSQL1);
drSQL1.Close();
DataSource1_DefaultView.DataSource = dt1;
strSQL2 = "Select left(Last_Name,1) as Letter, Name from Corporate..Person_TBL";
SqlDataReader drSQL2 = cmdSQL2.ExecuteReader();
dt2.Load(drSQL2);
drSQL2.Close();
DataSource2_DefaultView.DataSource = dt2;
sqlConn.Close();
}
That seemed to do the trick! My next task is to do this same thing using the asp.net treeview control. I want to see what the difference in loading time is between the two.
Rich
Looks like a good example. But, why use hierarchical data source? What other methods are there for binding to a dataset, etc.? And, which is the best method? The samples give an example for MSAccess (very useless).