asp.net - Rearrange child repeaters within a parent repeater -
i have set of nested repeaters structure this:
repeater repeater a-1 repeater a-2 repeater a-3 repeater b repeater b-1 repeater b-2 repeater b-3
i want dynamically rearrange child repeaters within parent repeater @ run-time. example, based on user configuration, might want change order of repeater a's children 2,3,1. i'm open either server or client-side solution.
i argue client side jquery approach. avoid postbacks, 1990's these days. if able wrap repeater content sort of container element , supply them id attributes write reusable jq function rearranging you.
asp.net code: (you have similar)
<asp:repeater datasource="<%#source%>" runat="server"> <itemtemplate> <div id="containera"> <asp:repeater datasource="<%#container.dataitem%>" runat="server"> <itemtemplate> <div id="a-<%# bind("count") %>"><%#someevaluatedmethod()%></td> </itemtemplate> </asp:repeater> </div> </itemtemplate> </asp:repeater>
generated html:
<div id="containera"> <div id="a1">some text</div> <div id="a2">some text</div> <div id="a3">some text</div> </div>
to arrange divs via jquery:
to avoid re-inventing wheel, take @ these examples, there couple working examples here. choose makes sense , project.
Comments
Post a Comment