Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Friends,

Am working on Asp.net C#, GRIDVIEW , SqlServer 2005.

I have Created a program in Asp.net c# and Database as SqlServer 2005.

My SqlServer Database will Update the data for every 1 Minute. So am displaying this data in Gridview.

So my problem is What should i use to update my GRID for every 1 minute.

Script Manager
Updatepanel, Content Template
Timer..

Can i use Timer for this ? or else I can Use Updatepanel.

Please help me.

THANKS
Posted

Please refer following code. I hope that helps.:)
Also you have to add Script Manager.

<asp:updatepanel id="UpdatePanel1" runat="server" xmlns:asp="#unknown">

<contenttemplate>

<asp:timer id="Timer1" runat="server" interval="3600" ontick="Timer1_Tick">

<asp:gridview id="gvContact" runat="server" autogeneratecolumns="False" datakeynames="ContactID">

DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True">

<columns><asp:boundfield datafield="ContactID" headertext="ContactID" readonly="True" sortexpression="ContactID" />

<asp:boundfield datafield="CompanyName" headertext="CompanyName" sortexpression="CompanyName" />

<asp:boundfield datafield="ContactName" headertext="ContactName" sortexpression="ContactName" />

<asp:boundfield datafield="Address" headertext="Address" sortexpression="Address" />

<asp:boundfield datafield="City" headertext="City" sortexpression="City" />






protected void Timer1_Tick(object sender, EventArgs e)

{

gvContact.DataBind();

}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900