Note that there are some explanatory texts on larger screens.

plurals
  1. POListView with TextBoxes in UpdatePanel does not return values after OnTextChanged
    primarykey
    data
    text
    <p>I have a <strong>ListView</strong> with <strong>TextBoxes</strong> in it. When I enter a value in the TextBox A I want a calculated value to show up in TextBox B. I am doing this in the CodeBehind. This works well until I place the ListView in an <strong>UpdatePanel</strong>.</p> <p>On the <strong>OnTextChanged</strong> I would like to do some calculations/database actions (In the example beneath I just multiply the inserted value by 2). Since I do not want to do a complete <strong>PostBack</strong> everytime I enter a value, I inserted an UpdatePanel. Also because I want to stay on the same scroll position.</p> <p><strong>The first time</strong> I enter a value the OnTextChanged method does everything as it should, but <strong>the second time</strong> the UpdatePanel seems to remove all calculated values and only returns the first inserted value.</p> <p>In Debug mode everything works well, also in IE8, but not in FireFox,Chrome or IE9. I assume I am not using the UpdatePanel as I should be?</p> <p>aspx page:</p> <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Testing.aspx.cs" Inherits="Sales_NewOrderPOS" ClientIDMode="AutoID"%&gt; &lt;asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server"&gt; &lt;/asp:Content&gt; &lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server"&gt; &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt; &lt;/asp:ScriptManager&gt; &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt; &lt;ContentTemplate&gt; &lt;asp:ListView ID="ListView1" runat="server" DataSourceID="ObjectDataSource1"&gt; &lt;LayoutTemplate&gt; &lt;table&gt; &lt;asp:PlaceHolder runat="server" ID="itemPlaceholder"&gt;&lt;/asp:PlaceHolder&gt; &lt;/table&gt; &lt;/LayoutTemplate&gt; &lt;ItemTemplate&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:Label ID="lblItemNo" Text='&lt;%# Eval("ItemNo") %&gt;' runat="server"&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:Label ID="lblItemDecription" Text='&lt;%# Eval("ItemDescription") %&gt;' runat="server"&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID="txtPalletQuantity" runat="server" Width="30px" OnTextChanged="TextChangedPallet" AutoPostBack="true" &gt;&lt;/asp:TextBox&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID="txtUnitQuantity" runat="server" Width="30px"&gt;&lt;/asp:TextBox&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/ItemTemplate&gt; &lt;/asp:ListView&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="SP_SelectItems" TypeName="ItemClass"&gt; &lt;/asp:ObjectDataSource&gt; &lt;/asp:Content&gt; </code></pre> <p>Code Behind:</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { } protected void TextChangedPallet(object sender, EventArgs e) { TextBox txtPalletQuantity = (TextBox)sender; ListViewItem item = (ListViewItem)txtPalletQuantity.NamingContainer; TextBox txtUnitQuantity = (TextBox)item.FindControl("txtUnitQuantity"); txtUnitQuantity.Text = ((Convert.ToDecimal(txtPalletQuantity.Text) * 2)).ToString(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload