Last post Jan 21, 2011 12:40 AM by decker dong - msft
Jan 19, 2011 01:22 PM|hsobhy|LINK
I need to know what is the difference and which is better (load spead, performance and security wise) between including and binding a Repeater and the XML DataSource in my code behind and between making all on the control.ascx
If Not Page.IsPostBack Then
Dim xmlSource As New XmlDataSource()
xmlSource.DataFile = MapPath("pages.xml")
xmlSource.XPath = "sitemap/language[@id='1']/nav[@nav='True']"
rpPages.DataSource = xmlSource
<asp:Repeater id="rpPages" runat="server">
<li><%# DataBinder.Eval(Container.DataItem, "title") %></li>
And the other way:
<asp:XmlDataSource id="dsNav" DataFile="pages.xml" XPath="sitemap/language[@id='1']/page[@nav='True']" runat="server"/>
<asp:repeater id="dlPages" DataSource='<%# XPathSelect("page") %>' runat="server">
<li><%# XPath("@name") %></li>
Wha's the different and when should I use one better than the other?
Thank you all in adbance
Jan 21, 2011 12:40 AM|Decker Dong - MSFT|LINK
Generally speaking, both of the datasources are the same in their concpets. The second is recommanded because you can design in UI, which is easy
for you to review or view the result. However, the first is dynamic, which means you can load datasource manually at any time you'd like.