In c# are you using Timer control and set interval as you want and use update panel for do not refresh page
please see under below design code
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:Timer ID="Timer1" runat="server" Interval="10000">
</asp:Timer>
</div>
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:DataGrid ID="grvDemo" runat="server" Width="100%" GridLines="Both" HeaderStyle-BackColor="AntiqueWhite"
AutoGenerateColumns="true">
</asp:DataGrid>
</ContentTemplate>
</asp:UpdatePanel>
And Code Side :
using System.Data;
using System.Data.SqlClient;
protected void Page_Load(object sender, EventArgs e)
{
BindGrid();
}
public void BindGrid()
{
//SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
SqlConnection con = new SqlConnection("Data Source=BITPLUS5\\SqlExpress;Initial Catalog=temp;User ID=sa;pwd=bit123;");
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select * from chat order by 1";
cmd.Connection = con;
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
grvDemo.DataSource = dr;
grvDemo.DataBind();
}
Dhaval PatelPosted Dec 11, 2011, 11:47 PM
the database is polled every 120 seconds. If the data in the database and table changes during that time, any data that is cached by the SqlDataSource control and displayed by the GridView control is refreshed by the SqlDataSource control the next time the database is polled. are you right erode using sqlcachedependancy no server load.... But also you are using json to get data using sqlcachedependancy
SenthilkumarPosted Dec 10, 2011, 7:02 AM
if the timer keep on running in the particular interval even data updated or not. some of the web sites like cricket score update it may fine. But take the shopping cart... There are 5 items initially and page not refreshed for 5 times but one of the items sold out... so there are only 5 items. Here refresh for every 2 mins will make performance issues. Consider busy shopping portal with 2 Lakhs users online... then think about the server load... Please try the sqlcachedependancy in 2.0 onwards...