循环遍历泛型集合List绑定到table

  1 <%@ Page Language="C#" AutoEventWireup="true" EnableViewState="false" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
  2 
  3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4 
  5 <html xmlns="http://www.w3.org/1999/xhtml">
  6 <head runat="server">
  7     <title></title>
  8 </head>
  9 <style>
 10 table { background:#D3E4E5;
 11  border:1px solid gray;
 12  border-collapse:collapse;
 13  color:#fff;
 14  font:normal 12px verdana, arial, helvetica, sans-serif;
 15 }
 16 caption { border:1px solid #5C443A;
 17  color:#5C443A;
 18  font-weight:bold;
 19  letter-spacing:20px;
 20  padding:6px 4px 8px 0px;
 21  text-align:center;
 22  text-transform:uppercase;
 23 }
 24 td, th { color:#363636;
 25  padding:.4em;
 26 }
 27 tr { border:1px dotted gray;
 28 }
 29 thead th, tfoot th { background:#5C443A;
 30  color:#FFFFFF;
 31  padding:3px 10px 3px 10px;
 32  text-align:left;
 33  text-transform:uppercase;
 34 }
 35 tbody td a { color:#363636;
 36  text-decoration:none;
 37 }
 38 tbody td a:visited { color:gray;
 39  text-decoration:line-through;
 40 }
 41 tbody td a:hover { text-decoration:underline;
 42 }
 43 tbody th a { color:#363636;
 44  font-weight:normal;
 45  text-decoration:none;
 46 }
 47 tbody th a:hover { color:#363636;
 48 }
 49 tbody td+td+td+td a  
 50 {
 51  background-position:left center;
 52  background-repeat:no-repeat;
 53  color:#03476F;
 54  padding-left:15px;
 55 }
 56 tbody td+td+td+td a:visited  
 57 {
 58  background-position:left center;
 59  background-repeat:no-repeat;
 60 }
 61 tbody th, tbody td { text-align:left;
 62  vertical-align:top;
 63 }
 64 tfoot td { background:#5C443A;
 65  color:#FFFFFF;
 66  padding-top:3px;
 67 }
 68 .odd { background:#fff;
 69 }
 70 tbody tr:hover { background:#99BCBF;
 71  border:1px solid #03476F;
 72  color:#000000;
 73 }</style>
 74 <body>
 75     <form id="form1" runat="server">
 76     <div>
 77         <table cellpadding="0" cellspacing="0">
 78             <thead>
 79                 <tr class="odd">
 80                     <th style="width:40px"> 编号</th>
 81                    <th style="width:40px">
 82                        性别</th>
 83                    <th style="width:40px">
 84                        姓名</th>
 85                    <th style="width:40px">
 86                        名族</th>
 87                    <th style="width:40px">
 88                        日期</th>
 89                    <th style="width:40px">
 90                        其他</th>
 91                        <th style="width:40px">
 92                        </th>
 93                        <th style="width:40px">
 94                        </th>
 95                         <th style="width:40px">
 96                        </th>
 97             </tr>
 98             </thead>
 99             
100                  <%
101 
102   int Count=party.Count();
103 
104   for (int i = 0; i < Count; i++)
105   {
106       if (i % 2 == 0)
107       {
108            %>
109     
110   <tr class="odd">
111     <td><%=party[i].Jmsfzh%></td>
112     <td><% =party[i].Xm %></td>
113     <td><% =party[i].Xb %></td>
114     <td><% =party[i].Mz %></td>
115     <td><% =party[i].Csrq %></td>
116     <td><% =party[i].Szdzb %></td>
117     <td>增加</td>
118     <td>修改</td>
119     <td>删除</td>
120 
121     </tr>
122 
123   <%}
124       else
125       {
126           %>
127     
128   <tr>
129     <td><%=party[i].Jmsfzh%></td>
130     <td><% =party[i].Xm %></td>
131     <td><% =party[i].Xb %></td>
132     <td><% =party[i].Mz %></td>
133     <td><% =party[i].Csrq %></td>
134     <td><% =party[i].Szdzb %></td>
135     <td>增加</td>
136     <td>修改</td>
137     <td>删除</td>
138 
139     </tr>
140 
141   <%
142       }
143       
144       }
145 
146   %>
147         </table>
148 
149 
150 <%-- <asp:GridView ID="grv" runat="server">
151         </asp:GridView>--%>
152     </div>
153     </form>
154 </body>
155 </html>

 

posted @ 2013-07-05 11:11  哪啊哪啊神去村  阅读(1775)  评论(0编辑  收藏  举报