2
我想在我的ASP.NET網站來計算學生的總加權平均(GWA)asp.net ListView,在腳註中顯示計算得出的摘要?
我的公式是(在SQL)
ROUND(SUM((UnitsAcademic*Grade))/SUM(UnitsAcademic),3)
到目前爲止,這是我的ASP.NET。我想要使用ASP.NET來計算GWA。現在我有點卡住了。
ASPX
<asp:ListView OnItemDataBound="listviewGrade_ItemDataBound" ID="listviewGrade" runat="server" DataSourceID="sqlGrade" DataKeyNames="GradebookDetailId">
<LayoutTemplate>
<table class="Container8" >
<tbody>
<tr>
<th>Subject Code</th>
<th>Description</th>
<th>Units</th>
<th>Grade</th>
<th>Remarks</th>
<th>Faculty Name</th>
</tr>
<tr id="itemPlaceholder" runat="server" />
</tbody>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td><%# Eval("SubjectCode") %></td>
<td><%# Eval("Description") %></td>
<td><asp:Label ID="lblUnitsAcademic" runat="server" Text='<%# Eval("UnitsAcademic") %>' /></td>
<td><asp:Label ID="lblGrade" runat="server" Text='<%# Eval("Grade") %>' /></td>
<td><%# Eval("Remarks") %></td>
<td><%# Eval("FacultyName") %></td>
</tr>
</ItemTemplate>
</asp:ListView>
<br/>
<asp:Label ID="lblGWA" runat="server" />
C#
protected void listviewGrade_ItemDataBound(object sender, ListViewItemEventArgs e)
{
Label lblGrade = (Label)e.Item.FindControl("lblGrade");
Label lblUnitsAcademic = (Label)e.Item.FindControl("lblUnitsAcademic");
}