我使用下面的JavaScript代码来获取行总计和网格视图的总计
但问题是$Cost
值来自DropDownList dllcost
因此,当我使用DropDownList更改成本值时,总价值不会根据所选的成本值进行更新。
JavaScript代码
<script>
$(document).ready(function () {
$(".txtMult input").on('keyup mouseup', multInputs);
function multInputs() {
var $mult = 0;
var $mgrandvalue = 0;
$("tr.txtMult:gt(0):lt(-1)").each(function () {
var $Cost = $('.Cost', this).val();
var $MarketValue = $('.MarketValue', this).val();
var $Quantity = $('.Quantity', this).val();
var $total = $Cost * $Quantity;
var $mvalue = $MarketValue * $Quantity;
$mult += $total;
$mgrandvalue += $mvalue;
$('.multTotal', this).text($total.toFixed(2));
$('.mvalue', this).text($mvalue.toFixed(2));
});
$(".lblGrandCost").text($mult.toFixed(2));
$(".lblGrandmvalue").text($mgrandvalue.toFixed(2));
}
});
</script>
网格视图
<asp:GridView ID="griditem" OnRowDataBound="griditem_RowDataBound" CssClass="table table-borded text-nowrap" GridLines="None" runat="server" ShowFooter="True" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderStyle-Width="225" ControlStyle-Width="225" HeaderText="Item">
<ItemTemplate>
<asp:DropDownList DataValueField="ItemID" AutoPostBack="true" OnSelectedIndexChanged="dllitem_SelectedIndexChanged" DataTextField="ItemName" ID="dllitem" CssClass="form-control" runat="server"></asp:DropDownList>
</ItemTemplate>
<HeaderStyle />
</asp:TemplateField>
<asp:TemplateField HeaderStyle-Width="225" ControlStyle-Width="225" HeaderText="Cost">
<ItemTemplate>
<asp:DropDownList ID="dllcost" CssClass="form-control Cost" runat="server"></asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-Width="109" ControlStyle-Width="109" HeaderText="Market Value">
<ItemTemplate>
<asp:TextBox ID="txtmvalue" TextMode="Number" min="0" step="any" CssClass="form-control MarketValue" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-Width="109" ControlStyle-Width="109" HeaderText="Quantity">
<ItemTemplate>
<asp:TextBox ID="txtQuantity" TextMode="Number" min="0" CssClass="form-control Quantity" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-Width="50" HeaderText="Total Cost">
<ItemTemplate>
<asp:Label ID="lbltotalcost" CssClass="multTotal" runat="server"></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblgrandcost" Text="" runat="server" CssClass="lblGrandCost" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-Width="50" HeaderText="Total M.Value">
<ItemTemplate>
<asp:Label ID="lbltotalmv" CssClass="mvalue" runat="server"></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lbltotalmvfooter" Text="" runat="server" CssClass="lblGrandmvalue" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
答案 0 :(得分:1)
您需要为下拉列表添加更改事件,如下所示。
let countDic: [String: AnyObject] = [
"a" : 1 as NSNumber,
"b" : "no" as NSString,
"c" : 2 as NSNumber
]
let countDicContainsString = countDic.contains {
key, value in //<- `value` is inferred as `AnyObject`
value is String //<- true when value is a String, false otherwise
}
print(countDicContainsString) //->true