www.webdeveloper.com
Results 1 to 4 of 4

Thread: [RESOLVED] Treeview with Contentplaceholders

  1. #1
    Join Date
    Mar 2011
    Location
    Nijmegen
    Posts
    10

    resolved [RESOLVED] Treeview with Contentplaceholders

    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="<&#37;$ 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
    Last edited by JohanVeldkamp; 04-12-2011 at 09:57 AM. Reason: some thing to it

  2. #2
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367
    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
    ----------------------------------

  3. #3
    Join Date
    Mar 2011
    Location
    Nijmegen
    Posts
    10

    Problemn Solved

    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">
    <aspetailsView 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>
    </aspetailsView>
    <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>

  4. #4
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367
    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
    ----------------------------------

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles