日期:2014-05-17 浏览次数:20537 次
<table border="1" align="left" cellspacing="0" bordercolor="#196ce3" rules="all" style="border: 1px solid #196ce3; border-collapse: collapse; height:237px; width: 1001px;"> <tr> <td colspan="5" align="center" height="60"><strong>成绩表</strong></td> </tr> <tr> <td rowspan="2" align="center" width="150"> <strong> 得分情况 </strong> </td> <td colspan="4" align="center"><strong> c程序设计 </strong></td> </tr> <tr > <td align="center" style="cursor:hand;"> <strong>简单题</strong></td> <td align="center" style="cursor:hand;"> <strong>中等题</strong></td> <td align="center" style="cursor:hand;"> <strong>难题</strong></td> <td align="center" style="cursor:hand;"> <strong>总分</strong></td> </tr> <asp:Repeater ID="Repeater4" runat="server" onitemdatabound="Repeater4_ItemDataBound" > <ItemTemplate> <tr> <td width="150" align="center" height="30"><%# Eval("chapter").ToString() %></td> <asp:Repeater ID="Repeater3" runat="server" > <ItemTemplate> <td width="50" align="center"><strong> <%# Eval("e_score").ToString() %></strong></td> <td width="50" align="center"><strong> <%# Eval("m_score").ToString()%></strong></td> <td width="50" align="center"><strong> <%# Eval("d_score").ToString()%></strong></td> <td width="50" align="center"><strong> <% # [color=#FF0000]这里是要绑定的总分[/color] %></strong></td> </ItemTemplate> </asp:Repeater> </tr> </ItemTemplate> </asp:Repeater> </table>
protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { Repeater4Bind(); } } protected void Repeater4Bind() { string sql = "select distinct chapter from student_score where sid='" + Session["uid"].ToString() + "' order by chapter"; Common comm = new Common(); DataSet ds = comm.GetDataSet(sql); Repeater4.DataSource = ds.Tables[0].DefaultView; Repeater4.DataBind(); } protected void Repeater4_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Repeater rep = e.Item.FindControl("Repeater3") as Repeater; // 找到里层的repeat