<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);
}
}