RadListView with a Repeater, problems with postback.

4 posts, 0 answers
  1. Chris
    Chris avatar
    3 posts
    Member since:
    Jun 2012

    Posted 24 Jul 2012 Link to this post

    I am using a repeater within my RadListView which has the data source set like DataSource='<%# Bind("ContactDetails") %>'.

    So then I can loop through the different properties of the ContactDetails and use them, but when I update any data in these fields the data is lost on post back.

    I have read quite a lot of different blog posts etc and they seem to think I need to bind in the Onint method, but since I don't bind in the code behind, I have no idea how to do this, or if this will actually solve my problem.

    The data source for the RadListView is calling a WCF web Service that expects JSON.

    Here is an example of the code I am using....
    Please ignore any small syntax errors, I have quickly shortend this code for putting on the forums.

    <telerik:RadListView ID="RadListView1" runat="server" DataSourceID="ObjectDataSource1" Skin="Hay">
        <ItemTemplate>
            <asp:Repeater ID="ContactDetails" runat="server" DataSource='<%# Bind("ContactDetails") %>'>
                <ItemTemplate>
                    <asp:Label ID="ContactDetailLabel" runat="server"
                        AssociatedControlID="ContactDetailTextBox"
                        Text='<%# Bind("ContactDetailType") %>'></asp:Label>
                    <asp:TextBox ID="ContactDetailTextBox" runat="server" CssClass="rlvInput"
                        Text='<%# Bind("Value") %>' />
                </ItemTemplate>
            </asp:Repeater>                    
            <asp:Button ID="UpdateButton" runat="server" CommandName="Update"
                Text="Update Profile" ToolTip="Update" />
        </ItemTemplate>
    </telerik:RadListView>

    Any help would be great, I am totally stuck on this one. Is it even possible to do what I want?

  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 27 Jul 2012 Link to this post

    Hi Chris,

    The data is lost because the Repeater creates new controls when it is bound during the postback, so the ContactDetailTextBox will get the value from the datasource again.
    You need to use a control that actually supports data editing like RadGrid or RadListView and not Repeater control.

    Greetings,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Chris
    Chris avatar
    3 posts
    Member since:
    Jun 2012

    Posted 27 Jul 2012 Link to this post

    Hi,

    Thank you very much for the reply :)

    So is it going to be as simple as replacing the repeater with a RadListView?

    Regards,
    Chris
  5. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 30 Jul 2012 Link to this post

    Hi Chris,

    Yes, it should be okay. You can write here if you have some problems using the ListView after migrating the project.

    All the best,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top