Use the asp+ DataGrid control to create a master/detail view

Source: Internet
Author: User
Tags microsoft sql server xmlns visual studio
asp+|datagrid| Create | control | View INTRODUCTION

The next release of Microsoft®visual Studio.NET includes the DataGrid Web control as part of the Active server page+ (asp+) suite of server controls. The control provides functionality to represent HTML based on the contents of the data source.

The DataGrid control can be used for several read-only reporting scenarios. The control is designed to simplify the output of a rich and fully customizable data table layout. It also provides several mechanisms for adding interactivity to the output through hyperlinks and their support for selection, sorting, paging, and in-place editing and other features. This makes the control useful in a number of common WEB application scenarios, such as lists, shopping carts, and query results.

The DataGrid also provides features that feature all server controls that are unique to the asp+ architecture. The control contains the logic required for browser-independent output, while providing a unified programming model to handle the return data and manage the state between requests. In this way, developers can program on object models with attributes, methods, and events without having to deal with inconsistencies and complexities that are directly associated with HTML programming.

Use the Asp+ list-bound control (English) to introduce the DataGrid control and the associated DataList and Repeater controls. It also introduces several key concepts of data binding, templates, and formatting. The article is written on this basis and focuses on the DataGrid control to reveal how to take advantage of the functionality provided by the control in your own application.


--------------------------------------------------------------------------------


What are we going to build?

This article cites a sequence of sample pages that combine to produce a page that, based on the Authors table and Titles table of the example database, provides a master/detail view that is shipped with Microsoft SQL server™2000. Each page in the sequence describes a new feature or feature of the DataGrid control. The following images are extracted from the pubs database.

The master/detail view is similar to the form/subform concept that Microsoft Access describes. Also similar to the DataForm Wizard (Data Form Wizard) shipped with Microsoft Visual interdev®6.0. The Master/Detail view displays one or more relationship results, where one part of the view displays the results of the first query or the main query. A selection is then tracked to filter the results of the second query used, displaying details of the selection in another part of the view.



Figure 1. Finished page

Figure 1 Displays the Author list in the top half of the page and displays detailed information about the selected author (including related titles) in the lower part. Authors lists and Titles are represented by the DataGrid control. The DataGrid that displays the author illustrates how to select, Sort, and page out. The DataGrid showing the title shows how to edit, format, and customize columns in situ.

Data access

To make the example self-contained, extract the data from SQL Server and leave the data together with its schema information as an XML file titlesdb.xml. The following is a fragment of the file.

<root>
<schema id= "documentelement" targetnamespace= ""
Xmlns= "Http://www.w3.org/1999/XMLSchema"
Xmlns:msdata= "Urn:schemas-microsoft-com:xml-msdata" >
<element name= "Author" >
<complextype content= "Elementonly" >
<element name= "au_id" type= "string" minoccurs= "1"
maxoccurs= "1" ></element>
<element name= "Au_name" type= "string" minoccurs= "1"
maxoccurs= "1" ></element>
<element name= "Address" type= "string" minoccurs= "0"
maxoccurs= "1" ></element>
<element name= "City" type= "string" minoccurs= "0"
maxoccurs= "1" ></element>
<element name= "state" type= "string" minoccurs= "0"
maxoccurs= "1" ></element>
<element name= "Zip" type= "string" minoccurs= "0"
maxoccurs= "1" ></element>
<element name= "Phone" type= "string" minoccurs= "0"
maxoccurs= "1" ></element>
</complexType>
<unique name= "Authorconstraint" msdata:primarykey= "True" >
<selector>.</selector>
<field>au_id</field>
</unique>
</element>

<element name= "Title" >
<complextype content= "Elementonly" >
<element name= "title_id" type= "string" minoccurs= "1"
maxoccurs= "1" ></element>
<element name= "au_id" type= "string" minoccurs= "1"
maxoccurs= "1" ></element>
<element name= "title" Type= "string" minoccurs= "1"
maxoccurs= "1" ></element>
<element name= "Price" msdata:datatype= "System.currency"
Type= "string"
minoccurs= "1" maxoccurs= "1" ></element>
<element name= "pubdate" type= "Timeinstant" minoccurs= "1"
maxoccurs= "1" ></element>
</complexType>
<unique name= "Titleconstraint" msdata:primarykey= "True" >
<selector>.</selector>
<field>title_id</field>
</unique>
<key name= "AuthorTitle" >
<selector> /author</selector>
<field>au_id</field>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.