This article describes the use of XML in ASP.net, which only shows the use of XML in conjunction with a dataset. In fact, asp.net on the operation of XML and the object is a lot of, such as Xmldatadocument,xmltextreader, these objects are fully functional, but also very practical.
This article takes the XML used by the AdRotator control as an example (the novice can look at the usage of the AdRotator control) and write an ad management program. This program, the control used by flying cutter is mainly a DataGrid, you can say that the DataGrid has been used almost all the functions, we are concerned about the XML at the same time, you can learn how to use the DataGrid.
Let us explain some of the methods used in this example:
Datasets are mainly used in ReadXml and WriteXml methods. Their function to see the name to know, flying knives are not wordy. A lot of methods and objects are used in the DataGrid. For example pagination uses the AllowPaging property, the sort uses the AllowSorting attribute, in this case all events in the DataGrid, such as Onitemcommand,oneditcommand,oncancelcommand, are used. Onupdatecommand and so on.
Look carefully at the handling of these events.
In addition, when you look at the program, think again, if this program uses ASP to write how many pages, oh, with ASP.net only need one page, and unlimited use, this is the advantages of asp.net.
In the program I made some simple comments, the most important thing is everyone's understanding.
Oh, recently our studio people are busy a step confused, so please forgive us. Flying knives These days is not not write procedures, just write procedures need to be published in the book, (for example, and the pursuit of the same function of the Web page, really can achieve the same function as the pursuit, no false) can not be posted online. This will be scolded:)
Let's take a look at the contents of the XML file we're working with: <?xml version= "1.0" standalone= "yes"?
<advertisements>
<xsd:schema id= "Advertisements" targetnamespace= "xmlns=" "
Xmlns:xsd= "Http://www.w3.org/1999/XMLSchema"
Xmlns:msdata= "Urn:schemas-microsoft-com:xml-msdata" >
<xsd:element name= "Ad" >
<xsd:complextype content= "Elementonly"
<xsd:all>
<xsd:element name= "ImageUrl" minoccurs= "0" type= "xsd:string"/>
<xsd:element name= "NavigateUrl" minoccurs= "0" type= "xsd:string"/>
<xsd:element name= "AlternateText" minoccurs= "0" type= "xsd:string"/>
<xsd:element name= "Keyword" minoccurs= "0" type= "xsd:string"/>
<xsd:element name= "Impressions" minoccurs= "0" type= "xsd:string"/>
</xsd:all>
</xsd:complextype>
</xsd:element>
<xsd:element name= "Advertisements" msdata:isdataset= "True"
<xsd:complextype>
<xsd:choice maxoccurs= "unbounded"
<xsd:element ref= "Ad"/>
</xsd:choice>
</xsd:complextype>
</xsd:element>
</xsd:schema>
<ad>
<imageurl>aspcn_bbs1.gifc</imageurl>
<navigateurl>HTTP://WWW.ASPCN.COM/BBS</NAVIGATEURL>
<alternatetext>Www.knowsky.com</AlternateText>
<keyword>bbs</keyword>
<impressions>50</impressions>
</ad>
<ad>
<imageurl>aspcn_bbs3.gif</imageurl>
<navigateurl>HTTP://WWW.ASPCN.COM/BBS</NAVIGATEURL>
<alternatetext>Www.knowsky.com</AlternateText>
<keyword>bbs</keyword>
<impressions>50</impressions>
</ad>
<ad>
<imageurl>aspcn_bbs2.gifc</imageurl>
<navigateurl>HTTP://WWW.ASPCN.COM/BBS</NAVIGATEURL>
<alternatetext>Www.knowsky.com</AlternateText>
<keyword>bbs2</keyword>
<impressions>50</impressions>
</ad>
<ad>
<imageurl>HTTP://WWW.ASPCN.COM/ASPCN.GIF</IMAGEURL>
<navigateurl>HTTP://WWW.ASPCN.COM</NAVIGATEURL>
<alternatetext>Www.knowsky.com</AlternateText>
<keyword> Juan Ricoh Bang?/keyword>
<impressions>80</impressions>
</ad>
<ad>
<imageurl>HTTP://WWW.ASPCN.COM/ASPCN.GIF</IMAGEURL>
<navigateurl>HTTP://WWW.ASPCN.COM</NAVIGATEURL>
<alternatetext>Www.knowsky.com</AlternateText>
<keyword>Www.knowsky.com/Keyword>
<impressions>80</impressions>
</ad>
<ad>
<imageurl>HTTP://WWW.ASPCN.COM/ASPCN.GIF</IMAGEURL>
<navigateurl>HTTP://WWW.ASPCN.COM</NAVIGATEURL>
<alternatetext>Www.knowsky.com</AlternateText>
<keyword>Www.knowsky.com/Keyword>
<impressions>80</impressions>
</ad>
<ad>
<imageurl>HTTP://WWW.ASPCN.COM/ASPCN.GIF</IMAGEURL>
<navigateurl>HTTP://WWW.ASPCN.COM</NAVIGATEURL>
<alternatetext>Www.knowsky.com</AlternateText>
<keyword>Www.knowsky.com/Keyword>
<impressions>80</impressions>
</ad>
<ad>
<imageurl>HTTP://WWW.ASPCN.COM/ASPCN.GIF</IMAGEURL>
<navigateurl>HTTP://WWW.ASPCN.COM</NAVIGATEURL>
<alternatetext>Www.knowsky.com</AlternateText>
<keyword>Www.knowsky.com/Keyword>
<impressions>80</impressions>
</ad>
<ad>
<imageurl>HTTP://WWW.ASPCN.COM/ASPCN.GIF</IMAGEURL>
<navigateurl>HTTP://WWW.ASPCN.COM</NAVIGATEURL>
<alternatetext>Www.knowsky.com</AlternateText>
<keyword>Www.knowsky.com/Keyword>
<impressions>80</impressions>
</ad>
<ad>
<imageurl>HTTP://WWW.ASPCN.COM/ASPCN.GIF</IMAGEURL>
<navigateurl>HTTP://WWW.ASPCN.COM</NAVIGATEURL>
<alternatetext>Www.knowsky.com</AlternateText>
<keyword>Www.knowsky.com/Keyword>
<impressions>80</impressions>
</ad>
<ad>
<imageurl>HTTP://WWW.ASPCN.COM/ASPCN.GIF</IMAGEURL>
<navigateurl>HTTP://WWW.ASPCN.COM</NAVIGATEURL>
<alternatetext>Www.knowsky.com</AlternateText>
<keyword>Www.knowsky.com/Keyword>
<impressions>80</impressions>
</ad>
<ad>
<imageurl>HTTP://WWW.ASPCN.COM/ASPCN.GIF</IMAGEURL>
<navigateurl>HTTP://WWW.ASPCN.COM</NAVIGATEURL>
<alternatetext>Www.knowsky.com</AlternateText>
<keyword>Www.knowsky.com/Keyword>
<impressions>80</impressions>
</ad>
<ad>
<imageurl>HTTP://WWW.ASPCN.COM/ASPCN.GIF</IMAGEURL>
<navigateurl>HTTP://WWW.ASPCN.COM</NAVIGATEURL>
<alternatetext>Www.knowsky.com</AlternateText>
<keyword>Www.knowsky.com</Keyword>
<impressions>98090</impressions>
</ad>
<ad>
<imageurl>HTTP://WWW.ASPCN.COM/ASPCN.GIF</IMAGEURL>
<navigateurl></navigateurl>
<alternatetext>Www.knowsky.com</AlternateText>
<keyword>Www.knowsky.com</Keyword>
<impressions>98090</impressions>
</ad>
<ad>
<imageurl>HTTP://WWWASPCN.COM</IMAGEURL>
<navigateurl>HTTP://</NAVIGATEURL>
<alternatetext></alternatetext>
<keyword></keyword>
<impressions></impressions>
</ad>
</advertisements>
There are some problems in Chinese, but in the following program can be normal display, because of the internationalization of technology, haha, this example with a lot of stuff yo:
This is the standard format XML referenced by the AdRotator control.
Let's take a look at the final display of the program.