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

RadListView with a Repeater, problems with postback.

3 Answers 113 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 24 Jul 2012, 08:45 AM
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?

3 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 27 Jul 2012, 08:36 AM
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.
0
Chris
Top achievements
Rank 1
answered on 27 Jul 2012, 08:48 AM
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
0
Vasil
Telerik team
answered on 30 Jul 2012, 08:06 AM
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.
Tags
ListView
Asked by
Chris
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Chris
Top achievements
Rank 1
Share this question
or