GridView生成的HTML代码示例对比

时间:2022-09-01 20:18:15

代码如下:


<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" CssClass="tablecss"> 
<Columns> 
<asp:TemplateField HeaderText="编号" HeaderStyle-CssClass="aaa" ItemStyle-CssClass="bbb"> 
<ItemTemplate> 
<%#Eval("id") %> 
</ItemTemplate> 
</asp:TemplateField> 
<asp:TemplateField HeaderText="姓名" HeaderStyle-CssClass="aaa" ItemStyle-CssClass="bbb"> 
<ItemTemplate> 
<%#Eval("name") %> 
</ItemTemplate> 
</asp:TemplateField> 
</Columns> 
</asp:GridView> 
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 
<div> 
<table class="tablecss" cellspacing="0" rules="all" border="1" id="Table1" style="border-collapse: collapse;"> 
<tr> 
<th class="aaa" scope="col">编号</th> 
<th class="aaa" scope="col">姓名</th> 
</tr> 
<tr> 
<td class="bbb">1</td> 
<td class="bbb">张三</td> 
</tr> 
<tr> 
<td class="bbb">2</td> 
<td class="bbb">李四</td> 
</tr> 
</table> 
</div>