如何在vb .net的行末的gridview单元格中获取总值?

时间:2014-11-07 04:58:34

标签: vb.net webforms

我创建了一个名为gv reports的网格视图,并添加了像area,ccreated,congoing,caccepted,cclosed和ctotal这样的列。

<asp:GridView ID="gvreport" runat="server" BorderStyle="Solid" BorderWidth="1px" 
                  CellPadding="3" EnableModelValidation="True" AutoGenerateColumns="False" 
                  BackColor="White"
      BorderColor="#999999" ForeColor="Black" GridLines="Vertical" Width="691px" 
                  ShowFooter="True">
                  <AlternatingRowStyle BackColor="#CCCCCC" />
                  <Columns>

<asp:BoundField DataField="PermitAreaName" HeaderText="PermitAreaName" FooterText="GrantTotal" />
                            <asp:TemplateField HeaderText="cCreated">

                            <FooterTemplate>
                            <asp:Label ID="fcCreated" runat="server" Text="Label"></asp:Label>
                            </FooterTemplate>

                            <ItemTemplate>
<asp:Label ID="lblcCreated" runat="server" Text='<%# Bind("cCreated", "{0}") %>'></asp:Label>
                            </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="cOnGoing">

                            <FooterTemplate>
<asp:Label ID="fcOnGoing" runat="server" Text="Label"></asp:Label>
                            </FooterTemplate>

                            <ItemTemplate>
<asp:Label ID="lblcOnGoing" runat="server" Text='<%# Bind("cOnGoing", "{0}") %>'></asp:Label>
                            </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="cAccepted">
                            <FooterTemplate>
<asp:Label ID="fcAccepted" runat="server" Text="Label"></asp:Label> 
                            </FooterTemplate>
                            <ItemTemplate>
<asp:Label ID="lblcAccepted" runat="server" Text='<%# Bind("cAccepted", "{0}") %>'></asp:Label>
                            </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="cClosed">

                            <FooterTemplate>
<asp:Label ID="fcClosed" runat="server" Text="Label"></asp:Label>
                            </FooterTemplate>

                            <ItemTemplate>
<asp:Label ID="lblcClosed" runat="server"  Text='<%# Bind("cClosed", "{0}") %>'></asp:Label>
                            </ItemTemplate>
                            </asp:TemplateField>
<asp:TemplateField HeaderText="cTotal">
                            <FooterTemplate>
<asp:Label ID="fcTotal" runat="server" Text="Label"></asp:Label>
                            </FooterTemplate>
                            <ItemTemplate>
<asp:Label ID="lblctotal" runat="server"></asp:Label>
                            </ItemTemplate>
                            </asp:TemplateField>
                            </Columns>
                            <FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="Black" HorizontalAlign="Center" BackColor="#999999" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
                             </asp:GridView>

Protected Sub gvreport_RowDataBound(sender As Object, e As 
System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvreport.RowDataBound
    ' check row type
e.Row.Cells(5).Text = e.Row.Cells(1).Text + e.Row.Cells(2).Text + e.Row.Cells(3).Text + 
e.Row.Cells(4).Text

        End If
    End If
End Sub

我希望以列方式和行方式获得网格视图单元格的值的总和。 请帮忙。

0 个答案:

没有答案