<asp:GridView ID="GridView_Stores" runat="server" OnRowDataBound="GridView1_RowDataBound" ShowFooter="True" AllowSorting="false" HTMLEncoded="false" AutoGenerateColumns="true" DataSourceID="myDataSource" ShowHeaderWhenEmpty="True"/>...
无论源/连接/自动生成与否,正文标题或项目模板中的第一行始终包含空白<tr><th scope="col">
或<tr><td>
;它不会结束,也不会终止。我找不到删除的方法。
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
string ptn = "$#,###;<span style='color:rgb(255,0,0);'>($#,###)</span>;-";
if (e.Row.RowType == DataControlRowType.DataRow)
{
SalesTotal += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "sales"));
RentalTotal += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "rental"));
PartsTotal += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "parts"));
ServiceTotal += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "service"));
OverallTotal += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "total"));
}
if (e.Row.RowType == DataControlRowType.Footer)
{
Literal TtalSales = (Literal)e.Row.FindControl("TtalSales");
TtalSales.Text = SalesTotal.ToString(ptn);
Literal TtalRental = (Literal)e.Row.FindControl("TtalRental");
TtalRental.Text = RentalTotal.ToString(ptn);
Literal TtalParts = (Literal)e.Row.FindControl("TtalParts");
TtalParts.Text = PartsTotal.ToString(ptn);
Literal TtalService = (Literal)e.Row.FindControl("TtalService");
TtalService.Text = ServiceTotal.ToString(ptn);
Literal TtalTotal = (Literal)e.Row.FindControl("TtalTotal");
TtalTotal.Text = OverallTotal.ToString(ptn);
}
}