AJAX: DataBinding Issue

by Brad 16. January 2008 17:22

I've just spent a while pulling my hair out trying to find out why some text in my repeater control wasn't updating after postback on one page but was on another. The repeater was in a UserControl I'd made, and the same control was on both pages - the only difference - once was inside an AJAX UpdatePanel and on the other page it wasn't.

Here's the offending code:

<ItemTemplate>
    <tr>
       <td><asp:Image runat="server" ImageUrl='<%# Eval("Image") "%>' ID="iImage" /></td>
       <td><%# Eval("Score") %></td>
       <td><%# Eval("Percentage") %></td>
    </tr>
</ItemTemplate>

Now what was strange is that the image was updating ok (this confused me a lot while viewing it as the image is a bar representing the percentage figure and i spent ages working out while the image was wrong - before i noticed that it was the figure that was wrong not the image!)

Once I changed it to the following it worked fine:

<ItemTemplate>
    <tr>
        <td><asp:Image runat="server" ImageUrl='<%# Eval("Image") "%>' ID="iImage" /></td>
        <td><asp:Literal runat="server" Text='<%# Eval("Score") %>' ID="lScore" /></td>
        <td><asp:Literal runat="server" Text='<%# Eval("Percentage") %>' ID="lPercent" /></td>
    </tr>
</ItemTemplate>

The page that wasn't working contained an UpdatePanel holding a Dropdown box that causes my UserControl to rebind its Repeater control... Does anyone know why rebinding in the standard page works in a normal postback but not when inside an AJAX UpdatePanel?

Tags:

ASP.NET AJAX | C#

Powered by BlogEngine.NET 1.5.0.7
Theme by Interakting

Interakting

A full service digital agency offering online strategy, design and usability, systems integration and online marketing services that deliver real business benefits and ensure your online objectives are met.

Calendar

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar