日期:2014-05-17  浏览次数:20529 次

求个gridview查询显示结果后,某一列或多列分别求和,结果显示在label上
网上搜了半天,gridview的求和代码貌似都是清清月儿那个版本,可是在我这里貌似用不了,会提示“输入字符串的格式不正确”。

前台:

<asp:GridView ID="GridView1" runat="server" 
            BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" 
            CellPadding="3" AutoGenerateColumns="False" onrowdatabound="GridView1_RowDataBound">
            <Columns>
                <asp:TemplateField HeaderText="日期">                   
                    <ItemTemplate>
                        <asp:Label ID="lb_Date" runat="server" Text='<%# Bind("ExpDate") %>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" Width="70px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="名称">                   
                    <ItemTemplate>
                        <asp:Label ID="lb_Name" runat="server" Text='<%# Bind("UserName") %>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" Width="70px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="数量">                   
                    <ItemTemplate>
                        <asp:Label ID="lb_result" runat="server" Text='<%# Bind("ExpResult") %>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center