ASP.NET ListView: how to insert a "specific" element into every N elements?

I would like to do a โ€œweirdโ€ thing with the asp.net list control.

I would like to insert an advertisement for each element of the 8-10 list (linked to a database with a database table): for example, each element of 8-10 inserts google adwords jscript code.

I googoled, but I did not find anything. Someone knows whether itโ€™s possible to โ€œtell the list: every 8 points, show this element (google jscript code).

Excuse me for my poor English. Hope to be explained, thanks!

+4
source share
2 answers

You can achieve this effect by grouping your items. You will need the following:

  • LayoutTemplate in your ListView that contains groupPlaceholder
  • A group template in a ListView containing an itemPlaceholder
  • The GroupSeparatorTemplate panel containing your promotional materials.
  • ItemTemplate element containing data binding material

then you can configure your GroupSize the way you want, and ASP.Net will automatically add a separator between each group.

+6
source
for(int i = 0; i < limit; i++) { if(i % 8 == 0) addSpecialColumn(); } 

Hope this helps.

Here are a few theories.

0
source

Source: https://habr.com/ru/post/1309480/


All Articles