簡體   English   中英

如何使用Angular js計算GridView項目模板文本框值的兩個文本框值

[英]how to calculate two textbox values of a gridview items template text box values using Angular js

我想計算兩個文本框值,並在gridview另一個文本框中顯示結果。 gridview控件具有3列: qtyunit pricetotal 總列應使用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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM