Using UpdatePanels inside of a ListView

Posted by Jim B on Stack Overflow See other posts from Stack Overflow or by Jim B
Published on 2010-04-13T18:19:17Z Indexed on 2010/04/13 18:23 UTC
Read the original article Hit count: 533

Filed under:
|
|
|

Hey everyone,

I'm wondering if anybody has run across something similar to this before. Some quick pseudo-code to get started:

<UpdatePanel>
    <ContentTemplate>
        <ListView>
            <LayoutTemplate>
                <UpdatePanel>
                    <ContentTemplate>
                        <ItemPlaceholder />
                    </ContentTemplate>
                 </UpdatePanel>
            </LayoutTemplate>
            <ItemTemplate>
                 Some stuff goes here
            </ItemTemplate>
        </ListView>
    </ContentTemplate>
</UpdatePanel>

The main thing to take away from the above is that I have an update panel which contains a listview; and then each of the listview items is contained in its own update panel.

What I'm trying to do is when one of the ListView update panels triggers a postback, I'd want to also update one of the other ListView item update panels.

A practical implementation would be a quick survey, that has 3 questions. We'd only ask Question #3 if the user answered "Yes" to Question #1. When the page loads; it hides Q3 because it doesn't see "Yes" for Q1. When the user clicks "Yes" to Q1, I want to refresh the Q3 update panel so it now displays.

I've got it working now by refreshing the outer UpdatePanel on postback, but this seems inefficient because I don't need to re-evaluate every item; just the ones that would be affected by the prerequisite i detailed out above.

I've been grappling with setting up triggers, but i keep coming up empty mainly because I can't figure out a way to set up a trigger for the updatepanel for Q3 based off of the postback triggered by Q1.

Any suggestions out there? Am I barking up the wrong tree?

© Stack Overflow or respective owner

Related posts about c#

Related posts about listview