我有一个像这样的xml文档:
<NewDataSet>
<videos>
<video>
<name>name of video</name>
</video>
</videos>
<videos>
<video>
<name>name of video</name>
</video>
</videos>
</NewDataSet>
我希望能够在转发器中使用转发器来编辑存储在不同节点中的一些值。
protected void Page_Load(object sender, EventArgs e)
{
DataSet videos = new DataSet();
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("/my.xml"));
XmlNodeList nodes =
doc.SelectNodes("NewDataSet/videos");
rptVideosList.DataSource = nodes;
rptVideosList.DataBind();
}
protected void videoRepeater_ItemBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
XmlNode video = (XmlNode)e.Item.DataItem;
Repeater rptvideo = (Repeater)e.Item.FindControl("rptVideoList");
rptvideo.DataSource = video.ChildNodes;
rptvideo.DataBind();
}
}
<asp:Repeater ID="rptVideosList" runat="server" OnItemDataBound="videoRepeater_ItemBound">
<HeaderTemplate></HeaderTemplate>
<ItemTemplate>
<div style="border:solid 1px red; clear:both;">
videos
<asp:Repeater ID="rptVideoList" runat="server">
<HeaderTemplate></HeaderTemplate>
<ItemTemplate>
video
</ItemTemplate>
<ItemTemplate></ItemTemplate>
</asp:Repeater>
</div>
</ItemTemplate>
<FooterTemplate></FooterTemplate>
</asp:Repeater>
这似乎只是显示'视频'节点而不是'视频'节点。即前端只显示:
视频 视频
任何帮助将不胜感激
答案 0 :(得分:2)
内置中继器布局错误
<ItemTemplate>
video
</ItemTemplate>
<ItemTemplate></ItemTemplate>
删除一个<ItemTemplate></ItemTemplate>