![](/img/trans.png)
[英]how to pass two gridview textbox values to a javascript function
[英]how to calculate two textbox values of a gridview items template text box values using Angular js
我想計算兩個文本框值,並在gridview
另一個文本框中顯示結果。 gridview
控件具有3列: qty
, unit price
和total
。 總列應使用AngularJS
自動計算。 我無法綁定兩個文本框。它在總計列中為NaN
。
<div ng-app>
<asp:GridView runat="server" ID="gridviewCalc" AutoGenerateColumns="false" OnRowEditing="gridviewCalc_RowEditing" AutoGenerateEditButton="true">
<Columns>
<asp:TemplateField HeaderText="QTY" >
<ItemTemplate>
<asp:TextBox runat="server" Text='<%# Eval("qty")%>' ng-model="qty"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Unit Price">
<ItemTemplate>
<asp:TextBox runat="server" Text='<%# Eval("unitprice")%>' ng-model="unitprice"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total">
<ItemTemplate>
<asp:TextBox runat="server" Text='{{qty+unitprice}}'/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
而不是標簽試試這個
<span>
<%# String.Format("{0}",Convert.ToInt32(Eval("qty")) * Convert.ToInt32(Eval("unitprice"))) %>
</span>
對於文本框,請嘗試使用此方法綁定數據。
<asp:TextBox runat="server" Text='<%# Bind("qty")%>'/>
順便說一句,為什么當您擁有ASP渲染數據時,您只想進行角度計算。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.