views:

48

answers:

2

Hi at all, i would like to do a "weird" thing with the asp.net listview control.

I would like to insert advertising each 8-10 item of the listview (databounded with a database table) : for example each 8-10 item insert the google adwords jscript code.

I've googoled but i haven't found anything. Someone know if it's possible to "tell the listview: each 8 items, show this item (google jscript code).

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

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

Hope this helps.

Here's some theory.

Dänu
+4  A: 

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

  • a LayoutTemplate in your ListView that contains the groupPlaceholder
  • a GroupTemplate in your ListView that contains the itemPlaceholder
  • a GroupSeparatorTemplate that contains your ad stuff
  • an ItemTemplate that contains the databound stuff

then, you can set your GroupSize to whatever you want and ASP.Net will automatically insert a separator between each group.

DDaviesBrackett
This is really what i'm looking for ! Thank you Davies!
stighy