This is a migrated thread and some comments may be shown as answers.

RadTreeView not Binding

1 Answer 86 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Muhammad
Top achievements
Rank 1
Muhammad asked on 04 Sep 2012, 12:32 PM
Hi,

I am trying to bind my RadTreeView control but for some reason the (+) sign is not coming with parent node to expand it and bind child nodes on server side.

 Any help would be really appreciated.

Thanks

 
<telerik:RadTreeView runat="Server" ID="rtvUserProducts" Height="300" Width="300"
                                    Skin="Vista">
                                    <Nodes>
                                        <telerik:RadTreeNode Expanded="true" Text="Parent" ExpandMode="ServerSide" runat="server">
                                            <NodeTemplate>
                                                <asp:Label ID="lblProductName" Text='<%# Bind("ProductCodeAndDesc") %>' runat="server">
                                                </asp:Label>
                                                <asp:HiddenField ID="hidLogisticProductKey" Value='<%# Bind("LogisticProductKey") %>'
                                                    runat="server" />
                                            </NodeTemplate>
                                            <Nodes>
                                                <telerik:RadTreeNode Expanded="true" Text="Child" ExpandMode="ServerSide">
                                                    <NodeTemplate>
                                                        <asp:Label ID="lblUserName" Text='<%# Bind("UserName") %>' runat="server"></asp:Label>
                                                    </NodeTemplate>
                                                </telerik:RadTreeNode>
                                            </Nodes>
                                        </telerik:RadTreeNode>
                                    </Nodes>
                                </telerik:RadTreeView>


 Protected Sub LoadProductsInTreeView()


        Dim oDataTable As New DataTable
        Dim oConn As New SqlConnection(SprintDB.GetStockSystemConnectionString)
        Dim sSQL As String
        Dim sb As New StringBuilder
        sb.Append("select distinct lp.LogisticProductKey, ProductDescription + ' (' + ProductCode + ')' 'ProductCodeAndDesc' from stockAlertRecipients sar inner join LogisticProduct lp on lp.LogisticProductKey = sar.Filter")
        sSQL = sb.ToString
        Dim oAdapter As New SqlDataAdapter(sSQL, oConn)
        Try
            oAdapter.Fill(oDataTable)
            rtvUserProducts.DataTextField = "ProductCodeAndDesc"
            rtvUserProducts.DataValueField = "LogisticProductKey"
            rtvUserProducts.DataFieldParentID = "LogisticProductKey"
            rtvUserProducts.DataSource = oDataTable
            rtvUserProducts.DataBind()
            rtvUserProducts.ExpandAllNodes()
        Catch ex As Exception
            WebMsgBox.Show(ex.Message.ToString)
        End Try


    End Sub

1 Answer, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 05 Sep 2012, 12:17 PM
Hello Muhammad,

I noticed that you didn't set the DataFieldID, which is needed when you are setting the DataFieldParentID in order to build the TreeView.

I hope that helps.
Tags
TreeView
Asked by
Muhammad
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
Share this question
or