如表 t : id ,name, sex
1 我 男
顯示:
<table>
<td> 編號 </td> <td> 1 </td>
<td> 姓名 </td> <td> 我 </td>
<td> 姓別 </td> <td> 男 </td>
不放控件裏面
------解决方案--------------------------------------------------------
用repeater
用法如下:
<asp:repeater id= "Repeater " runat= "server " EnableViewState= "False ">
<ITEMTEMPLATE>
<tr align= "left ">
<td width= "109 " height= "19 " align= "center " valign= "middle "> <span class= "style6 "> <%# DataBinder.Eval(Container.DataItem, "Type ")%> </span> </td>
<td width= "153 " height= "19 " align= "center " valign= "middle " class= "style6 "> <%# DataBinder.Eval(Container.DataItem, "Name ")%> </td>
<td width= "159 " height= "19 " align= "center " valign= "middle " class= "style6 "> <%# DataBinder.Eval(Container.DataItem, "Model ")%> </td>
<td width= "162 " height= "19 " align= "center " valign= "middle " class= "style6 "> <%# DataBinder.Eval(Container.DataItem, "Num ")%> </td>
</tr>
</ITEMTEMPLATE>
</asp:repeater>
服务器端代码就是查询数据库得到数据后绑定这个repeater