我如何总结gridview的最后两列 [英] How do i sum the last 2 columns of my gridview
问题描述
我看了一些例子,他们都做了类似的事情,但我不明白如何为我的特定GridView编程。有人可以帮我解决这个问题吗。
I have looked at examples and they all do something similar but I don't understand how to program it for my specific GridView. Can someone help me figure this out Please.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1" DataSourceID="SqlDataSourceLookUpMilage" GridLines="None" ShowFooter="True">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="EmployeeName" HeaderText="EmployeeName" SortExpression="EmployeeName" />
<asp:BoundField DataField="VendorNumber" HeaderText="VendorNumber" SortExpression="VendorNumber" />
<asp:BoundField DataField="RecordDate" HeaderText="RecordDate" SortExpression="RecordDate" />
<asp:BoundField DataField="VisitNum" HeaderText="VisitNum" SortExpression="VisitNum" FooterText="TOTALS" />
<asp:BoundField DataField="Mileage" HeaderText="Mileage" SortExpression="Mileage" >
</asp:BoundField>
<asp:BoundField DataField="Total" HeaderText="$ Total" ReadOnly="True" SortExpression="Total" />
</Columns>
<EmptyDataTemplate>
<asp:TextBox ID="TextBox1" runat="server" Width="65px"></asp:TextBox>
</EmptyDataTemplate>
<FooterStyle BackColor="#999999" ForeColor="Black" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" Font-Bold="True" Font-Overline="False" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
<PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle BackColor="#DEDFDE" ForeColor="Black" />
<SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#594B9C" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#33276A" />
</asp:GridView>
我尝试了什么:
我试图在资源中使用这些示例,但我似乎无法使其工作对于我的GridView。我的SQL查询获取里程列中的值,并将其乘以里程率以获得$ Total。我希望在页脚中获得总里程数和总$。
What I have tried:
I have tried to use the examples in the resources but I can't seem to make it work for my GridView. My SQL query takes the values in the Mileage column and multiplies it by the mileage rate to get the $ Total. I want to have the total mileage and the total $ in the footer.
推荐答案
总计 ReadOnly = True < span class =code-attribute> SortExpression = 总计 / > ;
< /列 >
< EmptyDataTemplate >
< asp:TextBox ID = TextBox1 runat = server 宽度 = 65px > < / asp:TextBox >
< / EmptyDataTemplate >
< FooterStyle BackColor = #999999 ForeColor = 黑色 BorderColor = 黑色 BorderStyle = 实体 BorderWidth = 1px Font-Bold = True 字体上划线 = False / >
< HeaderStyle BackColor = #4A3C8C Font-Bold = 真 ForeColor = #E7E7FF / >
< PagerStyle BackColor = #C6C3C6 ForeColor = 黑色 HorizontalAlign = 右 / >
< RowStyle BackColor = < span class =code-keyword>#DEDFDE ForeColor = 黑色 / >
< SelectedRowStyle BackColor = #9471DE Font-Bold = True < span class =code-attribute> ForeColor = 白色 / > ;
< SortedAscendingCellStyle BackColor = #F1F1F1 / >
< SortedAscendingHeaderStyle BackColor = < span class =code-keyword>#594B9C / >
< SortedDescendingCellStyle BackColor = #CAC9C9 / >
< SortedDescendingHeaderStyle BackColor = #33276A / >
< / asp:GridView >
Total" ReadOnly="True" SortExpression="Total" /> </Columns> <EmptyDataTemplate> <asp:TextBox ID="TextBox1" runat="server" Width="65px"></asp:TextBox> </EmptyDataTemplate> <FooterStyle BackColor="#999999" ForeColor="Black" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" Font-Bold="True" Font-Overline="False" /> <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" /> <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" /> <RowStyle BackColor="#DEDFDE" ForeColor="Black" /> <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" /> <SortedAscendingCellStyle BackColor="#F1F1F1" /> <SortedAscendingHeaderStyle BackColor="#594B9C" /> <SortedDescendingCellStyle BackColor="#CAC9C9" /> <SortedDescendingHeaderStyle BackColor="#33276A" /> </asp:GridView>
我尝试了什么:
我试图使用资源,但我似乎无法使其适用于我的GridView。我的SQL查询获取里程列中的值并将其乘以里程率以获得
What I have tried:
I have tried to use the examples in the resources but I can't seem to make it work for my GridView. My SQL query takes the values in the Mileage column and multiplies it by the mileage rate to get the
Total。我希望页脚中的总里程数和总数
Total. I want to have the total mileage and the total
。
这篇关于我如何总结gridview的最后两列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!