Saturday, October 10, 2009

DreamwaverMX and ASP.NET(3)

3. uses Repeater component to show data set

Relevant introducing

The indication of the data in ASP.NET is varied, among them Repeater is another already some component. DataGrid always is met with " form " will reveal data, it is certain to want to use freer means to reveal data to wear when us can use Repeater to accuse,

It with Template(example) means will define data to output a format.

STEP 1. Build a page
We can be built through changing original page show data with Repeater component. Name Location1.htm again for Location1.aspx. Delete the original section in the page, build Dataset like on one chapter, choose Region_IDEnterValue=1 among them. We let accuse with Repeater below will make dynamic page.
J outputs a format to use example to define, build form first. We can look through page of Application à Databases

The structure of the database.



[Structure of graph 3-1 database]

Acc ording to the structure of the database, design following table.



[Graph 3-2 stencil pursues]
Need binds data below K in deciding form. the data in the Bindings in Application face plate in pulling its position.



[Dialog box of graph 3-3 Binding]

Data binds following pages receive after deciding:



[Graph 3-4 data binds the page after deciding]

Whether be like the feeling that ever was acquainted a bit, because Dreamwaver MX acceded,the tradition of UltraDev shows data with shining high. ③ also can choose the form of data presentation in Binding dialog box among them, the data of dot choosing page hind can be in Binding the form of corresponding data choice data presentation.



[The form of graph 3-5 data presentation]

If want to be example to show all number with this form,occupy, need to choose this form completely. The Server Behaviors in clicking Application face plate medium " + " , choose Repeat Region



[Graph 3-6 chooses 3-7 of graph of Repeat Region] [to choose reduplicative way]

Think reduplicative way certainly in Repeat Region, click OK. Can press now " F12 " preview a page.

STEP 2 analyses code(Attention: To can display code, all code are in under " < " later and " > " before added blank space, discomfort is excused more please! Discomfort is excused more please!!

<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 shows all data through building the pattern plate of an ItemTemple to repeat, be like the pattern that should set Repeater so, can come true through installing pattern plate.

We still can achieve the result that we want through adding other example.

AlternatingItemTemplate: Implementation acro ss shows data. Show data with the pattern plate across of former ItemTemplate

SepartorTemplate: Separator example. Can use at disjunctive data travel.

HeaderTemplate: Caption example. Show with place know exactly about sth is occupied most upper part.

FooterTemplate: Terminal example. Show with place know exactly about sth is occupied most lower part.

Its design a form to be the same as ItemTemplate same. The part that needs to want you to make pattern plate only is surrounded with tag can.

Will insert code to be able to have quick kind through Dreamwaver MX. Click the ASP.NET label of Insert face plate, click a mark next, can play a tag to add a dialog box. Choose the Templates project in ASP.NET Tags. You can choose you to want added code from which. Dreamwaver MX can input cursor to add code what be in locally so in you.



[Graph 2-1 adds tag dialog box]
AlternatingItemTemplate is below, separtorTemplate, headerTempl ate, the code of FooterTemplate, can insert its<ASP:REpeater ></ ASP:RIn Epeater > .

<Headertemplate ><Font Color="#666666" Size="4" >All

Location</ Font ></ Headertemplate >

<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 >

With respect to meeting ground when IIS analytic code key word puts pattern plate relative p osition, obtain the page that asks so.

The page that above program place makes is as follows:



[Graph 2-1 final page]

Repeater component can build freer page, but its can show a group of data each rows only. Want not to want to build more free page, that lets us enter DataList of below one husband to accuse will show data.

No comments:

Post a Comment