views:

34

answers:

2

Hi all.

I've created a wallboard application to display outstanding support calls for my ICT department. I've bound a number of gridviews to sqldatasources which execute a stored procedure. This is automated via asp.net ajax controls and partially refreshes the page/data every 30 seconds.

At the moment, when the number of records in the gridview goes over 9, the gridview automatically pages and shows the number of pages in the bottom right hand corner. The helpdesk can then VNC to the box which controls the screen and manually click to see what's on the next page.

What I am after is a way to programmatically (using the c# code-behind file) changing the current displayed page after 10/15 seconds or so, obviously if this is possible in the scope of the gridview. I trailed using javascript (and failed at jquery) of scrolling the gridview within a div, however this didn't work as expected.

Can anyone point me in the right example. I can't find anyone else querying this functionality via a quick Google. Any help/advice of how to fix this issue would be greatly appreciated!!

Gridview Code:

<asp:GridView ID="GridView1" ShowHeader="False" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" 
GridLines="None" CellPadding="2" Font-Size="35pt" AllowPaging="True" PageSize="9">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID">
<ItemStyle Width="15%" />
</asp:BoundField>
<asp:BoundField DataField="ASSIGNEES" HeaderText="ASSIGNEES" SortExpression="ASSIGNEES">
<ItemStyle Width="32%" Wrap="false"/>
</asp:BoundField>
<asp:BoundField DataField="title" HeaderText="title" SortExpression="title">
<ItemStyle Width="53%"  Wrap="false"/>
</asp:BoundField>
</Columns>
</asp:GridView>

SqlDataSource Code:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:FPConnectionString %>" SelectCommand="HDMonitoringOutstandingToday" SelectCommandType="StoredProcedure"></asp:SqlDataSource>

Link to printscreen of wallboard (not allowed to post images, damn newbie) >>> http://cl.ly/b48b88d9e5f9b7fa43ab

A: 
GridView.PageIndex 

You can change pages by setting the PageIndex, how you do it is up to you see here for some examples: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.pageindex.aspx

kyndigs
Great, thanks! Could I get the amount of pages, put it in an array and iterate through on the ontick event of a timer?
carlhunt3r
Numbers of pages is GridView.PageCount, but you dont need to put them into an array, if you use a OnTick you can just do GridView.PageIndex = GridView.PageIndex + 1, be sure to make sure you dont go over the number of pages you have, so do a check if pageindex equals pagecount then you must go back to page 1.
kyndigs
A: 

You can try something like this in a timer.

if(GridView1.PageIndex == GridView1.PageCount)
{
   GridView1.PageIndex = 0;
}
else
{
   GridView.PageIndex = GridView.PageIndex + 1;
}

I cant remember if you would need to add one to the PageIndex or not.

But anyway, the properties you need to work with are PageIndex and PageCount.

Jamie
Cheers! I'll have a go at this in the morning. I think I will have to use another ajax timer to tick inbetween the main page refresh tick (if you get me)
carlhunt3r
I have had to edit your example code to get the if statement to if (GridView1.PageIndex == (GridView1.PageCount - 1)) as PageCount is a zero based list! CHEERS :D
carlhunt3r