我有一些数据的 GridView:
<asp:GridView ID="gvSelected" runat="server"
AutoGenerateColumns = "False" Font-Names = "Arial"
EmptyDataText = "No Records Selected">
<Columns>
<asp:BoundField DataField = "ID" HeaderText = "ID" />
<asp:BoundField DataField = "Name" HeaderText = "Name" />
<asp:BoundField DataField = "Desc" HeaderText = "Description" />
<asp:BoundField DataField = "Price" HeaderText = "Price" />
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="txtAmount" runat="server" Text="0"
OnTextChanged="txtAmount_TextChanged" AutoPostBack="true">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lblResult" Text="0" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle BackColor="Green"></HeaderStyle>
</asp:GridView>
想要将“价格”与文本框中的一些金额相乘,结果将显示在带有标签 (lblResult) 的列中。我现在正在尝试使用 txtAmount_TextChanged 代码,之前有很多变化,但到目前为止没有结果......有什么建议!?
protected void txtAmount_TextChanged(object sender, EventArgs e)
{
TextBox amount= (TextBox)gvSelected.FindControl("txtAmount");
Label result = (Label)gvSelected.FindControl("lblResult");
score.Text = ((Convert.ToInt32(row)) * Convert.ToInt32(amount.Text)).ToString();
}