How to remove the automatically generated gridview table from Asp: Templatefield?

Asked

Viewed 28 times

0

How to remove the automatically generated gridview table from Asp: Templatefield?

I’m using a gridview like this

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<ul>
<li><%#Eval("Nome") %></li>
</ul>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

But when I run and see the source code of the page, this result is displayed:

<table cellspacing="0" rules="all" border="1" id="GridView1" style="border-
collapse:collapse;">

<tr>
<td>
<ul>
<li>Nome do usuario/li>
</ul>
</td>
</tr>

the more I want the result to be like this:

<ul>
<li>Nome do usuario</li>
</ul>

remembering that the language I am using is VB.NET

  • Use the repeater so in addition to being lighter the result is what you need

1 answer

0

I was able to solve the problem instead of using a Gridview I used a Datalist with the property RepeatLayout="Flow" that way my code went like this:

<asp:DataList ID="tabeladobanco" runat="server" RepeatLayout="Flow">
<ItemTemplate>
<li><%#Eval("Nome") %></li>
</ItemTemplate>
</asp:DataList>

Result of source code:

<ul>
<li>Nome do usuario</li>
</ul>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.