Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Binding the ASP.NET TreeView to a DataSet or an ObjectDataSource

, 1 May 2008
The TreeView can not bind to a DataSet or to an ObjectDataSource. With one line of code, you can do that now.
treeviewbindingtest.zip
TreeViewBindingTest
App_Data
bin
TreeViewBindingTest.dll
Properties
TreeViewBindingTest.csproj.user
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TreeViewBindingTest._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TreeView ID="TreeView1" runat="server">
            <DataBindings>
                <asp:TreeNodeBinding DataMember="System.Data.DataRowView" 
                    TextField="Text" ValueField="ID" />
            </DataBindings>
        </asp:TreeView>
    </div>
    </form>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Ralph Varjabedian
Technical Lead
Lebanon Lebanon
No Biography provided

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 2 May 2008
Article Copyright 2008 by Ralph Varjabedian
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid