日期:2014-05-18  浏览次数:20510 次

repeater嵌套
repeater嵌套问题,下面代码块是绑定嵌套repeater,这个是所有数据都循环绑定出来了,
我想要的是special数据全部绑定,spec_sun接收一个special的id,显示出当前子数据;其他spec_sun不绑定
C# code

<asp:Repeater ID="special" runat="server" OnItemDataBound="special_ItemDataBound">
<ItemTemplate>
    <div class="newsbt text bold"><a href="sal.aspx?typeid=<%#Eval("id") %>"><%#Eval("typename") %></a></div>
    <asp:Repeater ID="spec_sun" runat="server">
        <ItemTemplate>
            <div class="newsli text"><a href="salists.aspx?typeid=<%#Eval("id") %>"><%#Eval("typename") %></a></div>
        </ItemTemplate>
    </asp:Repeater>
</ItemTemplate>
</asp:Repeater>
    protected void special_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Repeater dt = (Repeater)e.Item.FindControl("spec_sun");
            DataRowView rowv = (DataRowView)e.Item.DataItem;
            int mainID = Convert.ToInt32(rowv["id"]);

            DataTable _dt = DST(mainID);
            if (_dt != null)
            {
                dt.DataSource = _dt;
                dt.DataBind();
            }
        }
    }




------解决方案--------------------
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater dt = (Repeater)e.Item.FindControl("spec_sun");
DataRowView rowv = (DataRowView)e.Item.DataItem;
int mainID = Convert.ToInt32(rowv["id"]);
if(mainID == 特殊id)
{
DataTable _dt = DST(mainID);
if (_dt != null)
{
dt.DataSource = _dt;
dt.DataBind();
}
}
}

------解决方案--------------------
参考:
嵌套
------解决方案--------------------
顶 慕白兄 ,我就不参活了
------解决方案--------------------
<td height="100%" valign="top" style="width: 183px">
<!--#############################开始#############################-->
<asp:repeater id="rptModLevel1" runat="server">
<itemtemplate>
<table width="178" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="178" align="left" background="images/meun_bg.gif" height="22" style="text-indent:32px;"><a href='main.aspx' target="mainFrame" onClick="showObj( <%# GetNextNum()%> )" title='<%# DataBinder.Eval(Container.DataItem, "series_name")%>'><font color="#023284"><%# SubString(DataBinder.Eval(Container.DataItem, "series_name").ToString(),9)%></font></a></td>

</tr>
</table>
<table width="178" height="4" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
</table>
<div id="odiv" style="DISPLAY:none">
<table width=&quo