Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using XML with ASP and the ASP:Repeater Please use speaker notes for additional information!

Similar presentations


Presentation on theme: "Using XML with ASP and the ASP:Repeater Please use speaker notes for additional information!"— Presentation transcript:

1 Using XML with ASP and the ASP:Repeater Please use speaker notes for additional information!

2 Stephen Daniels Sports Reporter 50000 Al Richards Engineering Consultant 95000 Jennifer Ames Foreign Consultant 55000 Sarah Grant Scientific Web 50000 Carl Hersey Foreign Consultant 60000 Continued...

3

4 sub Page_Load if Not Page.IsPostBack then dim payrollData=New DataSet payrollData.ReadXml(MapPath("payroll.xml")) payrollSet.DataSource=payrollData payrollSet.DataBind() end if end sub This is imported to allow us to work with DataSet objects. This creates a DataSet that I named payrollData for the XML file. When the page is loaded, the XML file is loaded into the DataSet to make it available Code continued on the next page... This establishes the DataSource and binds the DataSet to the Repeater control that you will see on the next page.

5 Employee List Last Name First Name Dept Job Salary The asp:Repeater is used with payrollSet (refer to previous slide). Finally, the closing of asp:Repeater, and the form. The is done only once and it is done first. The contents of the are repeated. As you can see looking at the output, each element in the XML is repeated. Like, the is rendered once - the table is ended. DataItems under Employee in the XML are repeated.

6

7 sub Page_Load if Not Page.IsPostBack then dim payrollData=New DataSet payrollData.ReadXml(MapPath("payroll.xml")) payrollSet.DataSource=payrollData payrollSet.DataBind() end if end sub Employee List Last Name First Name Dept Job Salary Continue...

8

9 sub Page_Load if Not Page.IsPostBack then dim payrollData=New DataSet payrollData.ReadXml(MapPath("payroll.xml")) payrollSet.DataSource=payrollData payrollSet.DataBind() end if end sub Employee List Last Name First Name Dept Job Salary

10

11 Programming Grocer Webmaster Grocer Networking Arruda Business Information Grocer Multimedia/Internet Vieira Computer Science Ferreira Information Systems Grocer Accounting Garand Marketing Management Leonard Retail Management Dickens Business Administration Leonard

12

13 sub Page_Load if Not Page.IsPostBack then dim optionData=New DataSet optionData.ReadXml(MapPath("bccopt.xml")) optionSet.DataSource=optionData optionSet.DataBind() end if end sub Option List Option Name Option Advisor

14 Programming Grocer Webmaster Grocer Stephen Daniels Sports Reporter 50000 Al Richards Engineering Consultant 95000 The root is bcc which is made up of option which has multiple occurrences and is basically the record. You can then think of the record as containing two fields: optionname and optionadv. The root is PERSONNEL which is made up of EMPLOYEE which has multiple occurrences and is basically the record. You can then think of the record as containing five fields: FIRST_NAME, LAST_NAME, DEPT, JOB and SALARY.

15 Computer Information Systems Career Programming Grocer Webmaster Grocer Networking Arruda Business Information Grocer Multimedia/Internet Vieira Transfer

16 Computer Science Ferreira Information Systems Grocer Business Career Accounting Garand Marketing Management Leonard Retail Management Dickens Transfer Business Administration Leonard

17 Computer Information Systems Career Programming Grocer As you can see, three tables were set up - one to deal with department, one to deal with optiontype and one to deal with option. Computer Information Systems is the first deptname within department (id is 0) and Business is the second deptname with department (id is 1). The relationships are expressed with nested set to true. Option is nested under optiontype and optiontype is nested under department.

18 The optiontype Table shows that Career is under the department with the id=0 and is optiontype=0. The next occurrence is Transfer which is still under department with id=0 and it has optiontype=0. The next occurrence of Career is with department id=1 and under optiontype it is 2 etc. The option Table shown here shows the optiontype id and then the optionname and option adviser. Note that the first group was under Computer Information Systems and Career and their were 5 options. You see this with optiontype having id=0 on the first 5. Computer Information Systems and Transfer had only two - you can also see that.

19 sub Page_Load if Not Page.IsPostBack then dim optionData=New DataSet optionData.ReadXml(MapPath("bccoptions.xml")) dgrTables.DataSource=optionData.Tables dgrTables.DataBind() dgrRelations.DataSource=optionData.Relations dgrRelations.DataBind() dgrDept.DataSource=optionData.Tables("department") dgrDept.DataBind() dgrOptTyp.DataSource=optionData.Tables("optiontype") dgrOptTyp.DataBind() dgrOptn.DataSource=optionData.Tables("option") dgrOptn.DataBind() end if end sub Defines a new DataSet named optionData which is related to the physical bccoptions.xml for reading. Establishes the Tables collection of the optionData dataset as the data source for the dgrTables datagrid and binds the data. Establishes the “option” table in the Tables collection of the optionData dataset as the data source for the dgrOptn datagrid within the tables collection of the DataSet and bind the data.

20 Tables Relationships department Table optiontype Table option Table

21 Here we can see the option which contains optionname and optionadv. Here we can see optiontype which includes typename and options. Here we can see department which includes deptname and optiontype. Here we recognize bcc.

22

23 sub Page_Load if Not Page.IsPostBack then dim optionData=New DataSet optionData.ReadXml(MapPath("bccoptions.xml")) xmpResults.InnerHtml = "" xmpResults.InnerHtml = optionData.getXmlSchema() & vbCrlf & vbCrlf xmpResultd.InnerHtml = "" xmpResultd.InnerHtml = optionData.getXml() & vbCrlf & vbCrlf end if end sub Option List

24

25 sub Page_Load if Not Page.IsPostBack then dim optionData=New DataSet optionData.ReadXml(MapPath("bccoptions.xml")) optionSet.DataSource=optionData.Tables("option") optionSet.DataBind() end if end sub Since there are three tables involved in the structure of bccoptions.xml, I need to specify which table in the Tables collection I want to use for this program. I am specifying the option table.

26 Option List Option Name Option Advisor On the previous slide (the beginning of this program), I defined optionSet as: optionSet.DataSource=optionData.Tables("option")


Download ppt "Using XML with ASP and the ASP:Repeater Please use speaker notes for additional information!"

Similar presentations


Ads by Google