Can I place a asp:datalist inside a repeater control and databind it?

懵懂的女人 提交于 2019-12-24 17:22:08

问题


Can I place a asp:datalist inside a repeater control and databind it for each time its repeated? Using VB.NET btw..

Cheers! --Jonesy


回答1:


Steps:
1. Nest the DataList in the Repeater
2. Bind each repeated Datalist during the Repeater's ItemDataBound event
3. Turn off their ViewStates,if they are not required.

Update:

i.e.

Script Side:

<asp:Repeater ID="Repeater1" runat="server">
        <ItemTemplate>
            <asp:DataList ID="DataList1" runat="server">
            </asp:DataList>
        </ItemTemplate>
        </asp:Repeater>

In Code:

Protected Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
        Dim DataList1 As DataList = DirectCast(e.Item.FindControl("DataList1"), DataList)
...Databind here ....

End Sub


来源:https://stackoverflow.com/questions/2552032/can-i-place-a-aspdatalist-inside-a-repeater-control-and-databind-it

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