Question

The following code used to work as expected until recently:

<asp:FormView runat="server" ID="FormView1" OnDataBound="FormView_OnDataBound" DefaultMode="Edit"
        OnItemUpdating="FormView1_OnItemUpdating"
        DataSourceID="FormViewDsObjectDS">
        <EditItemTemplate>
            <asp:Repeater runat="server" ID="RepeaterOfRepeaters" OnItemDataBound="RepeaterOfRepeaters_OnItemDataBound">
                <ItemTemplate>
                    <asp:Repeater runat="server" ID="TextBoxRepeater" OnItemDataBound="TextBoxRepeater_OnItemDataBound">
                        <ItemTemplate>
                            <asp:Label runat="server" ID="textLabel" Text='<%# Bind ("LabelText") %>'></asp:Label>
                            <telerik:RadTextBox runat="server" ID="txtBox" Text='<%# Bind ("Value") %>' OnTextChanged="txtBox_OnTextChanged" OnUnload="txtBox_OnUnload"></telerik:RadTextBox>
                            <telerik:RadTextBox runat="server" ID="noBindTxtBox" Text="initial value" />
                        </ItemTemplate>
                    </asp:Repeater>
                </ItemTemplate>
            </asp:Repeater>
            <telerik:RadButton runat="server" ID="submitButton" CommandName="Update" Text="Update"></telerik:RadButton>
        </EditItemTemplate>
    </asp:FormView>

I noticed that my txtBox.Text property is not updated in code behind after an edit when submitButton is pressed. Nor does noBindTxtBox.Text is updated as well. Since I am not the only one who is developing application I believe it may be a side effect of some other changes in the application. Aforementioned example works fine if extracted into a test application.

At the moment I am out of ideas how to pinpoint an exact problem which entails such behaviour. It seems like a lifecycle issue.

Since I am not an expert in asp.net maybe you could throw out some debugging/tracing ideas that would help me identify an issue?

By the way in FormView1_OnItemUpdating method I extract txtBox.Text value on submitButton click and it is not changed. The same is inside txtBox_OnUnload method. And txtBox_OnTextChanged is not even called after submit button click.

Update 2014-03-18

I subclassed RadTextBox in order to check whether the posted back data contains edited value or not.

public class RRadTextBox : RadTextBox {
    protected override bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection){
        return base.LoadPostData (postDataKey, postCollection);
    }
}

It turns out that it does not contain updated text box value. That is, postCollection[postDataKey] value is the same as initially set even after changing text box value. Does anybody know under which circumstances LoadPostData does not contain updated value just initial one?

Update 2014-03-19

When RRadTextBox is added directly in the form view EditItemTemplate I can see updated Text property value in LoadPostData method.

<EditItemTemplate>
        <serverControls:RRadTextBox runat="server" ID="directRRadTxtBox" Text="initial Text"/>

I would like to add that FormView is bound not in a PageLoad event but OnClick of a button. Thus repeaters are not bound during an edit.

Was it helpful?

Solution

There is nothing wrong with Repeater and FormView controls in this particular case. Apparently I had a JavaScript function which reset all text input controls created by the Repeater to their default values. This reset JS function was executed on the dialog close event. Furthermore I used to close the dialog which contained edit form in question together with a submit button click. Thus I couldn't see updated values in LoadPostData because they weren't there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top