Click to See Complete Forum and Search --> : [RESOLVED] Treeview with Contentplaceholders


JohanVeldkamp
04-12-2011, 09:54 AM
Hi There,

I am new to ASP.Net with ContentPlaceholders.
My problemn is:
I have a masterpage on which are 3 ContentPlaceHolders.
ContentPlaceholderLeft, ContentplaceholderContent, ContentplaceholderRight.
In the Left I have a treeview in the Contentpart I have a Detailsview.
When I click at the left the content has to be changed with the ControlParameter, this lead to an Error can't find ControlParameter p1 from treeview.

When I do the same thing in the page without contentholders it works perfect.

Other problemn is, the treeview I am using has to start at different points.
In the topmenu it can select the Headcategory which changes the start values of the tree. Sometimes I use an other table for the tree to show it.
Under is my code. At the menu_ParentId that will be different for each Headcategory and must change everytime I click in the topmenu.
Hope there is someone who figered this out earlier.

Many thanks,
Johan Veldkamp

<asp:Content ID="Content1" ContentPlaceHolderID="LeftContentPlaceHolder" Runat="Server">
Voor Wie
<asp:TreeView ID="VoorWieTree" ExpandDepth="1" PopulateNodesFromClient="true" ShowLines="False" ShowExpandCollapse="True" runat="server" />
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder" Runat="Server">
<asp: DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="Menu_Id" DataSourceID="menuitem_detail">
<Fields>
<asp:BoundField DataField="Menu_Id" HeaderText="Menu_Id" ReadOnly="True"
SortExpression="Menu_Id" Visible="false" />
<asp:BoundField DataField="Menu_Titel" HeaderText="Menu_Titel"
SortExpression="Menu_Titel" ShowHeader="false" />
<asp:BoundField DataField="Menu_Body" HeaderText="Menu_Body"
SortExpression="Menu_Body" ShowHeader="false" HtmlEncode="False" />
</Fields>
</asp: DetailsView>
<asp:SqlDataSource ID="menuitem_detail" runat="server"
ConnectionString="<%$ ConnectionStrings:BouwgegevensConnectionString %>"
SelectCommand="View_MenuItem" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="VoorWieTree" DefaultValue="1" Name="p1"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="RightContentPlaceHolder" Runat="Server">
</asp:Content>

Private Sub PopulateRootLevel()

Dim connectionString As String
connectionString = ConfigurationManager.ConnectionStrings("BouwgegevensConnectionString").ConnectionString

Dim objConn As New SqlConnection(connectionString)
Dim objCommand As New SqlCommand("select Menu_Id,Menu_Titel,(select count(*) FROM tbMenu " _
& "WHERE Menu_ParentID=sc.Menu_Id) childnodecount FROM tbMenu sc where Menu_ParentID = 1", objConn)

Dim da As New SqlDataAdapter(objCommand)
Dim dt As New DataTable()
da.Fill(dt)

PopulateNodes(dt, VoorWieTree.Nodes)

End Sub

Ribeyed
04-13-2011, 06:17 AM
Hi,

its hard to see what your trying to do when only part of the code and not the part you are asking about.

From what I'm reading you have a treeview and a dataview and you want to click on the treeview and update the dataview, can you show us the code you have so far?

The code you have give is just adding a few controls and databinding to the treeview. Where is the code you have tried? Can you show the code you have working and the code that doesn't work?

regards


Ribs

JohanVeldkamp
04-14-2011, 07:39 AM
Hi Ribs,

More searching on the web, I found the sollution for my problemn:
The text in red solved it. With the controlparameter in de contentplaceholder I want to get the "Querystring" the treeview. With using the wright ID, i got it working.

Thanks for your help allready.

Greetings,
Johan
<asp:Content ID="Content1" ContentPlaceHolderID="LeftContentPlaceHolder" Runat="Server">
Voor Wie
<asp:TreeView ID="VoorWieTree" ExpandDepth="1" PopulateNodesFromClient="true" ShowLines="False" ShowExpandCollapse="True" runat="server" />
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder" Runat="Server">
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="Menu_Id" DataSourceID="menuitem_detail">
<Fields>
<asp:BoundField DataField="Menu_Id" HeaderText="Menu_Id" ReadOnly="True"
SortExpression="Menu_Id" Visible="false" />
<asp:BoundField DataField="Menu_Titel" HeaderText="Menu_Titel"
SortExpression="Menu_Titel" ShowHeader="false" />
<asp:BoundField DataField="Menu_Body" HeaderText="Menu_Body"
SortExpression="Menu_Body" ShowHeader="false" HtmlEncode="False" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="menuitem_detail" runat="server"
ConnectionString="<%$ ConnectionStrings:BouwgegevensConnectionString %>"
SelectCommand="View_MenuItem" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="LeftContentPlaceHolder$VoorWieTree" DefaultValue="2" Name="p1"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>

Ribeyed
04-14-2011, 08:16 AM
Nice one thx for posting. It was looking like a referencing problem :)


Note: you should put BBcode tags around code so it doesn't swap emotes etc. plus its much easier to read.

regards


Ribs