views:

243

answers:

2

I have an asp:FormView with an ItemTemplate. I'd like to design the content within the FormView with some div elements:

<asp:FormView ID="MyFormView" runat="server" >
    <ItemTemplate>
        <div class="block1">
            Stuff...
        </div>
        <div class="block2">
            Stuff...
        </div>

        ...

        <div class="blockN">
            Stuff...
        </div>
    </ItemTemplate>
</asp:FormView>

When I run the application the following HTML is created:

<table id="MyFormView" style="border-collapse: collapse;" border="0" cellspacing="0">
    <tbody>
        <tr>
            <td colspan="2">
                <div class="block1">
                    Stuff...
                </div>
                <div class="block2">
                    Stuff...
                </div>

                ...

                <div class="blockN">
                    Stuff...
                </div>
            </td>
        </tr>
    </tbody>
</table>

Actually the table is somewhat disturbing. I don't know what's the purpose to have an ItemTemplate to freestyle the content but then wrap it into a table.

Is it possible to disable or work around this behaviour? (I couldn't find a flag in the FormView properties.)

A: 

use repeater (it is light version and fully customizable)

  <asp:Repeater runat=server ID="r1">
<HeaderTemplate><div></HeaderTemplate>
<ItemTemplate>Zzz</ItemTemplate>
<FooterTemplate></div></FooterTemplate>
</asp:Repeater>  

or

better use control adapters:

igor
Hm, what do you mean with the first option ("use your (div) templates")? Your markup example is exactly what I am doing, am I not?
Slauma
I am sorry. I recommend you using Repeater
igor
A: 

You can set RenderOuterTable="false" on the FormView

Clover