how to bind inner repeater?

﹥>﹥吖頭↗ 提交于 2019-12-04 15:43:12

If you have a header or footer in the parent repeater, your method might be executed for them too, and hence not finding the inner control.

Try to check if the e.Item.ItemType is "only" either ListItemType.Item or ListItemType.AlternatingItem, and only execute your code in this case.

Of course can't guarantee if this is the problem. Check also for confirming that repeater ID is correct, and verify that it's directly inside the item template of the parent repeater, not inside another server control inside the item (or else, you'll need to find the other control first and then find the repeater inside it).

Also, ensure you are using rep_hello ID not innerRepeater.

BTW< you can do this in the markup too...

<asp:repeater runat="server" id="innerRepeater"
    DataSource='<%# Eval("PropertyInParentObject") %>'  >
    ....
    ....
</asp:repeater>

You can use Container.DataItem instead of Eval too (and cast it to the type of the object in parent repeater item).

You are trying to find a repeater with the ID "innerRepeater". You should use "rep_hello" instead:

Protected Sub rep_test_ItemDataBound(ByVal sender As Object, ByVal e As   System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rep_test.ItemDataBound
    Dim dt As New DataTable
    dt = obj.getdata()
    Dim innerRepeater As Repeater = DirectCast(e.Item.FindControl("rep_hello"), Repeater)
    innerRepeater.DataSource = dt
    innerRepeater.DataBind()
End Sub
Ishfaq Ahmad

the follwing links will help you the most efficient way binding nested repeater 3 levels deep

msdn library

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!