Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ASP .NET Database Programming Weekend Crash Course - J. Butler, T. Caudill.pdf
Скачиваний:
33
Добавлен:
24.05.2014
Размер:
3.32 Mб
Скачать

230

Sunday Morning

The TREENODESRC Attribute can be any relative or fixed URL pointer, so the xml file could reside anywhere on your intranet or the internet.

Note

To obtain information on how to set up your Microsoft Internet Explorer WebControls visit http://msdn.microsoft.com/downloads/c-frame.htm?/ downloads/samples/internet/asp_dot_net_servercontrols/Webcontrols/ sample.asp

Listing 22-4 Example of binding a TreeView control bound to an xml file

<%@ Page Language=”VB” Debug=”true” Trace=”False”%> <%@ Import Namespace=”Microsoft.Web.UI.WebControls”%>

<%@ Register TagPrefix=”ie” Namespace=”Microsoft.Web.UI.WebControls” Assembly=”Microsoft.Web.UI.WebControls”%>

<HTML>

<HEAD>

</HEAD>

<BODY ID=”master”>

<FORM ID=”myform” RUNAT=”server”>

<IE:TREEVIEW RUNAT=”server” AUTOPOSTBACK=true ID=tvw1 CHILDTYPE=”Folder” SHOWPLUS=”True” TREENODESRC=”treeview.xml”>

<IE:TREENODETYPE TYPE=”Root” EXPANDEDIMAGEURL=”images/root.gif” IMAGEURL=”images/root.gif” CHILDTYPE=”Folder” />

<IE:TREENODETYPE TYPE=”Folder” EXPANDEDIMAGEURL=”images/folderopen.gif” IMAGEURL=”images/folder.gif” CHILDTYPE=”Item”/>

<IE:TREENODETYPE TYPE=”Item” IMAGEURL=”images/html.gif”/> </IE:TREEVIEW>

</FORM>

</BODY>

</HTML>

With this solution, we have illustrated the use of data binding to an XML stream, a powerful illustration of how we can easily leverage the ASP.NET framework to enhance the user experience.

The full source code for this example can be found in the Session 22 folder on the cd, under the filename treeveiwframeset.htm.

Note

REVIEW

We have covered the basics of data binding in this session and illustrated its use in a wide range of controls to facilitate dynamic user interface components. The ability to bind your server controls against such a range of data sources — from hash tables to arrays to custom classes — provides a wide range of flexibility in handling your user interface elements.

Session 22—Introducing Data Binding

231

QUIZ YOURSELF

1.Is it possible to bind server controls to each other? (See “Binding to Arrays and Extended Object Types.”)

2.What are the major differences between binding to an XML file and an ADO.NET dataset? (See “Binding to Database Data” and “Binding to XML.”)

3.List three elements that you can bind server controls to. (See “Binding to Arrays and Extended Object Types.”)