ListView losing values on post back.

2 posts, 0 answers
  1. fabian
    fabian avatar
    11 posts
    Member since:
    Dec 2010

    Posted 09 Jan 2012 Link to this post

    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;
                    }
            }
  2. jumpstart
    jumpstart avatar
    479 posts
    Member since:
    Nov 2011

    Posted 09 Jan 2012 Link to this post

    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!
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top