This is a migrated thread and some comments may be shown as answers.

ListView losing values on post back.

1 Answer 113 Views
ListView
This is a migrated thread and some comments may be shown as answers.
fabian
Top achievements
Rank 1
fabian asked on 09 Jan 2012, 04:34 PM
I have a list view with an item template and some radnumeric text boxes.
I'm binding the radnumerictextboxes programaticaly OnItemCreated.
When I fire a postback the values are all gone.
Any suggestions?
thank you

 <telerik:RadListView ID="RadListView1" runat="server" OnItemCreated="RadListView1_ItemCreated">
                <ItemTemplate>
                    <div>
                        <telerik:RadNumericTextBox ID="txb0" runat="server" Width="50px" />
                        <telerik:RadNumericTextBox ID="txb1" runat="server" Width="50px" />
                    </div>
                </ItemTemplate>
   </telerik:RadListView>

    protected void RadListView1_ItemCreated(object sender, RadListViewItemEventArgs e)
    {
                if (!IsPostBack)
                {
                    RadNumericTextBox txb0 = (RadNumericTextBox)e.Item.FindControl("txb0");
                    txb0.Value = 1;

                    RadNumericTextBox txb1 = (RadNumericTextBox)e.Item.FindControl("txb1");
                    txb1.Value = 2;
                }
        }

1 Answer, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 1
answered on 09 Jan 2012, 11:05 PM
Fabian:

Unfortunately, RadNumericTextBox is a type of RadInput, and as you can see in the radtextbox with password mode cant save its state while post back forum thread answered by Maria of Telerik (January 12, 2011): "The RadInput clear its value after each postback and this is by design due to security reasons."

So, you'd have to manually add the values to the ViewState or ControlState and reference them on the server-side. This could be a cumbersome task.

Hope this helps!
Tags
ListView
Asked by
fabian
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Share this question
or