Dreamwavermx and asp.net (iii)

Source: Internet
Author: User
asp.net

3. Display the dataset using the Repeater component

Related introduction

Asp. NET shows a variety of data, in which repeater is another existing component. The DataGrid always shows the data as a "table", and when we want to show the data in a more free way, we're going to use the Repeater control,

It defines the data output format in a template (boilerplate) way.

Step 1. Create a page
We can create a repeater component to display data by changing the original page. Rename the location1.htm to location1.aspx. Delete parts of the page and set up a dataset like the previous chapter, which filters region_identervalue=1. Let's use the Repeater control to do the dynamic page.

J to use a template to define the output format, first create a table. We can look through the applicationàdatabases page

The structure of the database.



[Figure 3-1 Database structure]

According to the structure of the database, design the following tables.



[Figure 3-2 Module Layout]

K you need to bind the data to the table below. Drag the data item in the bindings in the application panel to its location.



[Figure 3-3 Binding dialog box]

Data binding is followed by the following page:



[Figure 3-4 Data-bound page]

Is there a sense of déjà vu, because Dreamwaver MX inherits the Ultradev tradition to highlight the data. ③ where the Binding dialog box can also select the form of data representation, click the data item in the page to select the form of data representation in the corresponding data in binding.



[Figure 3-5 form of data representation]

To display all data items as a template for this table, select all of the tables. Click ' + ' in the server behaviors item in the application panel to select Repeat Region



[Figure 3-6 Select repeat Region] [Figure 3-7 Choosing the way to repeat]

In the repeat region, determine the way you want to repeat, click OK. You can now press "F12" to preview the page.

Step 2 Analysis Code(Note: In order to be able to display the code, all of the following code in the "<" and ">" before adding a space, inconvenience please forgive! )

< Asp:repeater runat= "server" Datasource= ' <% # Dataset1.defaultview% > ' >

< ItemTemplate >

< table width= "75%" border= "0" >

< tr >

< TD width= "18%" >location name</td >

< TD colspan= "3" > <% # dataset1.fieldvalue ("Location_name", Container)% > </td >

</tr >

< tr >

< TD >City</td >

< TD width= "35%" > <% # dataset1.fieldvalue ("City", Container)% > </td >

< TD width= "19%" >Address</td >

< TD width= "28%" > <% # dataset1.fieldvalue ("Address", Container)% > </td >

</tr >

< tr >

< TD >State</td >

< td > <% # dataset1.fieldvalue ("State_country", Container)% > </td >

< TD >Code</td >

< td > <% # dataset1.fieldvalue ("CODE", Container)% > </td >

</tr >

< tr >

< TD >Telephone</td >

< td > <% # dataset1.fieldvalue ("Telephone", Container)% > </td >

< TD >Fax</td >

< td > <% # dataset1.fieldvalue ("FAX", Container)% > </td >

</tr >

</table >

</itemtemplate >

</asp:repeater >

ASP.net is to repeatedly display all the data by creating a itemtemple template, so you can set the repeater style by setting up a template.

We can also add other templates to achieve the results we want.

AlternatingItemTemplate: Enables cross display of data. Cross-display data with the original ItemTemplate template

Separtortemplate: Separator template. can be used to separate rows of data.

HeaderTemplate: Title Sample. Displays the top of all data.

FooterTemplate: End model. Displays the bottom of all data.

It is designed in the same way as ItemTemplate. Simply enclose the part of the template you want to do with a tag.

Inserting code by Dreamwaver MX can have shortcuts. Clicking on the ASP.net tab of the Insert panel and clicking on the logo will bring up the tag to add the dialog box. Select the templates item in asp.net tags. You can choose which code you want to add. Dreamwaver MX adds code to the location where you originally entered the cursor.



[Figure 2-1 Add Tag dialog box]
The following is the code for Alternatingitemtemplate,separtortemplate,headertemplate,footertemplate, which can be inserted into < Asp:repeater ></ Asp:repeater >.

< HeaderTemplate >< font color= "#666666" size= "4" >all

location</font >
< AlternatingItemTemplate >

< table width= "75%" border= "0" bgcolor= "#CCCCCC" >

< tr >

< TD width= "17%" >location name</td >

< TD colspan= "3" bgcolor= "#CCCCCC" >

<% # Dataset1.fieldvalue ("Location_name", Container)% >

</td >

</tr >

< tr >

< TD >City</td >

< TD width= "34%" > <% # dataset1.fieldvalue ("City", Container)% > </td >

< TD width= "24%" >Address</td >

< TD width= "25%" > <% # dataset1.fieldvalue ("Address", Container)% > </td >

</tr >

< tr >

< TD >State</td >

< td > <% # dataset1.fieldvalue ("State_country", Container)% > </td >

< TD >Code</td >

< td > <% # dataset1.fieldvalue ("CODE", Container)% > </td >

</tr >

< tr >

< TD >Telephone</td >

< td > <% # dataset1.fieldvalue ("Telephone", Container)% > </td >

< TD >Fax</td >

< td > <% # dataset1.fieldvalue ("FAX", Container)% > </td >

</tr >

</table >

</alternatingitemtemplate >

< separatortemplate >< hr width= "70%" align= "left" >

</separatortemplate >

< FooterTemplate >< font color= "#666666" size= "4" >End</font ></footertemplate >

When IIS parses the code, it puts the template in a relative position according to the keyword, and gets the page that was originally requested.

The pages generated by the above program are as follows:



[Figure 2-1 Final page]

The repeater component can create more free pages, but each row can display only one set of data. If you want to create a more free page, let's go to the next DataList control to display the data.



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.