Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Tuesday, January 12, 2010 5:19 AM
I want to have a web page that shows the first 10 records of data.
I want it to wait 10 seconds and then show then next 10 records. How can I do
this?
This is for events like what you'd see on a digital sign in a train station.
All replies (8)
Thursday, January 14, 2010 2:08 AM âś…Answered
Hi,
Also, you can check this logical structure if you'd like. I will update the content only if the data has been changed.
http://forums.asp.net/t/1223393.aspx
Tuesday, January 12, 2010 5:46 AM
Refer here
http://aspsnippets.com/Articles/Reload-Refresh-and-Redirect-Pages-using-Meta-Tags-in-ASPNet.aspx
Tuesday, January 12, 2010 5:46 AM
You can use the Response.AddHeader method to force a timed reload or delayed refresh / redirection in an ASP page. The following code will cycle the current page every ten seconds (and is functionally equivalent to adding a <META REFRESH> tag to the HTML):
<%
Response.AddHeader "Refresh", "10"
%>
Tuesday, January 12, 2010 5:47 AM
Use the ajax timer control to make a call back every 10 secs. Make the trigger to be a hidden(style=display:none) button. In the hiddnen button increase the page size by one and again bind the records and this would be done
Tuesday, January 12, 2010 6:10 AM
You can use Ajax timer.
Also,you use gridview with a hidden footer,every time 10Sec elapsed by the Ajax timer then move to the next page (you need to use a gridview with AllowPaging = true),and when it reaches the last page you move to the first page and so on.
If you don't want to use Ajax timer,you can use javascript timer to refresh your page and handle everything in the page_load of your page.
This is the general idea.
Tuesday, January 12, 2010 6:19 AM
Hi,
Thanx for the reply.
Code
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim countpageindex As Integer
If Not IsPostBack = True Then
BindData()
countpageindex = GridData.PageCount
Session("currentpage") = countpageindex
Else
Dim currentpageindex As Integer
Dim getnextindex As Integer = Session("currentpage")
currentpageindex = GridData.PageIndex
If (currentpageindex + 1) = getnextindex Then
GridData.PageIndex = 0
Else
GridData.PageIndex = currentpageindex + 1
End If
BindData()
End If
End Sub
Tuesday, January 12, 2010 8:10 AM
Very simple,
I create this example for you,the purpose of this sample is to give an idea on what you have to do:
This is HTML:
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" PageSize="1">
<PagerSettings Visible="False" />
</asp:GridView>
<script type="text/javascript">
window.setInterval(function(){document.forms[0].submit();},10000);
</script>
</div>
</form>
And this is the code:
protected void Page_Load(object sender, EventArgs e)
{
if (ViewState["firstLoad"] == null)
{
FillData(true);
ViewState["firstLoad"] = "1";
}
else
{
FillData(false);
}
}
void FillData(bool firstLoad)
{
DataTable dt = new DataTable();
dt.Columns.Add("Destination");
dt.Columns.Add("Time of Arrival");
DataRow dr = dt.NewRow();
dr["Destination"] = "Amman";
dr["Time of Arrival"] = "10:30";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["Destination"] = "Aqaba";
dr["Time of Arrival"] = "13:30";
dt.Rows.Add(dr);
if (!firstLoad)
{
if (GridView1.PageIndex < GridView1.PageCount - 1)
{
GridView1.PageIndex += 1;
}
else { GridView1.PageIndex = 0; }
}
GridView1.DataSource = dt;
GridView1.DataBind();
}
Let me know the results
Tuesday, January 12, 2010 8:47 AM
Hi Ala'a Alnajjar
Thanks a lot. I finally managed to get it working. I have posted my VB Code. Once again thanx for helping.