Unknown repeater nested comment

Source: Internet
Author: User
Today, I saw a section on the Internet Code This is about repeater nesting. I hope you can help me solve this problem;

First look at the running effect:

XML file:

<? XML version = "1.0" encoding = "UTF-8" ?>
< Books >
< Book Type = "Computer" >
< Context > C Language </ Context >
< Context > C # Language </ Context >
< Context > C ++ Language </ Context >
</ Book >
< Book Type = "Fiction" >
< Context > Love Novels </ Context >
< Context > Zhiyin Novels </ Context >
< Context > Military Dynamics </ Context >
</ Book >
</ Books >

Background code:

Code
  Protected   Void Page_load ( Object Sender, eventargs E)
{
Dataset DS =   New Dataset ();
DS. readxml (server. mappath ( " Test. xml " ));
Repeater1.datasource = DS;
Repeater1.databind ();
}
Protected   Void Repeaterincluitemdatabound ( Object Sender, repeateritemeventargs E)
{
If (E. Item. itemtype = Listitemtype. Item | E. Item. itemtype = Listitemtype. alternatingitem)
{
Repeater P = (Repeater) E. Item. findcontrol ( " Repeater2 " );
Datarowview DRV = (Datarowview) E. Item. dataitem;
P. datasource = DRV. createchildview ( " Book_context " );
P. databind ();
}
}

Front-end code:

  < ASP: repeater ID = " Repeater1 " Runat = " Server " Onitemdatabound = " Repeaterincluitemdatabound " >
< Headertemplate >
Repeater Test </ Headertemplate >
< Footertemplate >
</ Footertemplate >
< Itemtemplate >
< Ul >
<% # Eval ( " Type " ) %>
< BR />
</ Ul >
< ASP: repeater ID = " Repeater2 " Runat = " Server " >
< Itemtemplate >
<% # Eval ( " Context_text " ) %> < BR />
</ Itemtemplate >
</ ASP: Repeater >
</ Itemtemplate >
</ ASP: Repeater >

What is unknown is:

1. P. datasource = DRV. createchildview ("book_context"); In "book_context", why is this parameter changed to another parameter? An error is returned:

The createchildview Method on msdn is described as follows:

If You can use Of Method To create Contains the rows in the relevant sub-table. It only describes the relationship between the parent table and the sub-table;

2. Code on the previous page

Code

code highlighting produced by actipro codehighlighter (freeware)
http://www.CodeHighlighter.com/

--> itemtemplate >
<% # eval ( " context_text " ) %> Br />
itemtemplate >

When setting the context in XML, only the context_text field can be used. If you change it to context, an error is returned. However, according to our general understanding, it should be a field in XML!

I have asked my friends in the garden to solve this problem. Thank you very much!

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.