Using AJAX to switch data in listview based on a 10 second interval.

Greetings.. and thank you for reading my post..

.NET Framework : 3.0
Language : C#
Visual Studio 2008.

I have this listview which is displayed as a "campain" on my mainpage of my website.
I'm using this objectdataSource which gets a set of data. It might return all from 1 to X (objects).

What i want to accomplish.. is to populate the listview with data from the first object --> 10 seconds --> fade-out --> populate listview with data from second object --> 10 seconds... etc.etc.etc... until the IList is empty.

So basically. i need to databind the listview with different data on each "reload"/"timer", but i have _NOO_ idea how to do this at the moment..

Any code help here would be greatly appreciated !..

It's a tricky question so it will be rewarded.

I have some code to display below :


THE LISTVIEW AND PANELS : 
<asp:UpdatePanel runat="server" ID="upnlCampain" UpdateMode="Conditional">
                    <ContentTemplate>
                        <asp:Panel runat="server" Width="100%" ID="pnlCampain">
                            <asp:ListView runat="server" ID="lvCampain" DataKeyNames="Id" DataSourceID="odsCampain"
                                OnItemCommand="lvCampain_OnItemCommand">
                                <LayoutTemplate>
                                    <asp:PlaceHolder runat="server" ID="itemPlaceholder" />
                                </LayoutTemplate>
                                <ItemTemplate>
                                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                            <td valign="top" width="70%">
                                                <table width="100%" border="0" cellspacing="2" cellpadding="2">
                                                    <tr>
                                                        <td>
                                                            <div style="float:left; vertical-align:top;">
                                                                <asp:ImageButton runat="server" ID="imgCampainChallenge" ImageUrl="~/gfx/challenge_icon_hover.gif" CommandName="View" CommandArgument='<%# Eval("displayIdeaId") %>' />
                                                            </div>
                                                            <div style="float:left; margin-left:10px; margin-top:5px">
                                                                <asp:Label runat="server" ID="lblCampainTitle" CssClass="campaintitle" Text='<%# Eval("Title") %>' Width="100%" /><br />
                                                                <asp:Label runat="server" ID="lblCampainText" CssClass="campaintext" Text='<%# Eval("Description") %>' />
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    
                                                    <tr>
                                                        <td valign="top">
                                                            <div style="width: 100%; display: block; padding:10px; background-color:#f8f8f8; border: dashed 1px #f2f1f1; width:100%">
                                                                
                                                                <asp:LinkButton runat="server" ID="lnkTitle" CssClass="plainlinkbuttonlarge" Text='<%# Eval("displayIdeaTitle") %>'
                                                                    Font-Size="Small" Font-Bold="True" CommandName="View" CommandArgument='<%# Eval("displayIdeaId") %>' />
                                                                <div style="float: left; padding-bottom: 10px; padding-top: 10px; width:100%;">
                                                                    <asp:Label runat="server" ID="labbelabb" CssClass="campaintextdefault" Text='<%# formatBackground(Eval("displayIdeaBackground")) %>' />
                                                                </div>
                                                                <div style="float: left; padding-top: 15px;">
                                                                    <asp:Label runat="server" ID="Label8" Text="opprettet " ForeColor="#999966" Font-Size="X-Small"
                                                                        Font-Italic="True" meta:resourcekey="Label8Resource1" />
                                                                    <asp:Label runat="server" ID="Label9" Text='<%# getDate(Eval("displayIdeaDate_Created")) %>'
                                                                        Font-Italic="True" Font-Size="X-Small" ForeColor="#999966" meta:resourcekey="Label9Resource1" />
                                                                    <asp:Label runat="server" ID="Label1" Text=" av " ForeColor="#999966" Font-Size="X-Small"
                                                                        Font-Italic="True" meta:resourcekey="Label1Resource1" />
                                                                    <asp:LinkButton runat="server" style="text-decoration:none" ID="lnkAuthor" Text='<%# Eval("displayUserFirstname") + " " + Eval("displayUserLastname") %>'
                                                                        Font-Size="X-Small" CommandName="ViewProfile" CommandArgument='<%# Eval("displayIdeaauthorId") %>'
                                                                        meta:resourcekey="lnkAuthorResource1" />
                                                                </div>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td valign="top">
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                            <td valign="top" width="30%">
                                                <table width="100%" border="0" cellspacing="2" cellpadding="2">
                                                    <tr>
                                                        <td valign="top">
                                                        <div style="vertical-align:middle; text-align:center;">
                                                            <asp:Imagebutton runat="server" ID="imgCampainReadMore" ImageUrl="~/gfx/campain_readmore.gif" CommandName="View" CommandArgument='<%# Eval("displayIdeaId") %>' />
                                                        </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td valign="top">
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </ItemTemplate>
                            </asp:ListView>
                            <asp:ObjectDataSource ID="odsCampain" runat="server" TypeName="Dao.initiativeDao, App_Code"
                                SelectMethod="activeCampain">
                                <SelectParameters>
                                    <asp:SessionParameter DefaultValue="0" SessionField="companyid" Name="companyid"
                                        Type="Int32" />
                                </SelectParameters>
                            </asp:ObjectDataSource>
                        </asp:Panel>
                    </ContentTemplate>
                </asp:UpdatePanel>
 
 
THE OBJECT DATASOURCE CODE : 
public IList Campain activeCampain(int companyid)
        {
            DetachedCriteria currentCampainCrit = DetachedCriteria.For<Campain>()
                               .CreateAlias("Company", "cpy")
                               .Add(Expression.Eq("Active", 1))
                               .Add(Expression.Eq("cpy.CId", companyid))
                               ;
            
Campain[] campainlist = Campain.FindAll(currentCampainCrit);
return campainlist.ToList<Campain>();
        }

Open in new window

NygterAsked:
Who is Participating?
 
CtrlAltDlConnect With a Mentor Commented:
Here is an article on how to do it:
http://ibuyspy.net/AJAX/Documentation/Live/tutorials/TimerControlWithUpdatePanelsTutorial.aspx

I've also included some code below.

<asp:Timer ID="Timer1" runat="server" Interval="100" OnTick="Timer1_Tick">
</asp:Timer>
<asp:UpdatePanel ID="upnlCampain" runat="server">
  <Triggers>
    <asp:AsyncPostBackTrigger ControlID="Timer1"
        EventName="Tick" />
    </Triggers>
</asp:UpdatePanel>
 
protected void Timer1_Tick(object sender, EventArgs e)
{
      upnlCampain.Update();
}

Open in new window

0
 
CtrlAltDlCommented:
Ok my previous posts takes care of the 10 second updatepanel refresh.  I just realized there is more to this question.

Are you talking about paging through results from a query every time it refreshes?
0
 
NygterAuthor Commented:
Thank you CtrlAltDl !

I'll check out the solution tomorrow morning..

Best regards Terje.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
NygterAuthor Commented:
Every time (each 10 seconds) it should change the data in the listview..

So.. it will start with the first object in the IList, then after 10 seconds.. switch the data to object two, until the list is empty..

So.. the objectDataSource will have a list of objects of type Idea. So i some how have to databind each "tick" to the next object in the list..

Hope that was understandable..

if you have more questions, i'll answer them in about 30 minutes.. quick trip home first :)

Terje.
0
 
NygterAuthor Commented:
Oh.. by the way.. it might be that the listview is not the way to go, feel free to recommend another display-control instead if you like.
0
 
CtrlAltDlCommented:
As far as fade-in and out on the updatepanel goes...

http://www.saintycorp.com/ajax/UpdatePanelAnimation/UpdatePanelAnimation.aspx
0
 
CtrlAltDlCommented:
The List control should be fine.  It should work with any data-based control.

So do you need to change the name of the object after each refresh (ie odsCampain1 -> odsCampain2 -> odsCampain3 -> etc...)?
0
 
NygterAuthor Commented:
Well.. Lets say it this way..

If i have 8 ideas registrered, and i have marked 5 of them that should be displayed in the listview control, since the field "active" is set to "1".

The ods will then pick those 5, into a list and return it to the listview.. The issue is that a listview takes all those 5 and puts them on the listview together. I want to display one after one with fading between them.. Just like a marketing banner :)

So the question is : how do i "manipulate" the listview control (or any simular control maybe?) to do what i'm after ? I want to display them all, but not together :)

So i need to do something "somewhere" in the code, that gets the first object and databinds it to the listview, then get the next one and databinds... etc.etc.etc...

Thanx for the help so far !

Terje.
0
 
NygterAuthor Commented:
Everything works now perfectly, now i just need to get the "fading issue" between the "ticks"..

any ideas CtrlAltDl ?

Tl
0
 
NygterAuthor Commented:
Great solution which led me in the right direction..
0
 
CtrlAltDlCommented:
Won't the UpdatePanelAnimationExtender do the job for you?
0
 
NygterAuthor Commented:
Hmm.. not sure how to do the updatepanelanimationextender mate :)

See this question :

http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_23805240.html
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.