DotNet Blogs

Articles of ASP.NET, C# & SQL Server

Auto Refresh update panel on page using Timer

Posted by Sujit Kumar on September 6, 2008

private void BindGridView()
{
string connectionString = @”Server=sujitkumar\sqlexpress;Database=pubs;uid=sa;pwd=1234;”;

SqlConnection conn = new SqlConnection(connectionString);
SqlDataAdapter ad = new SqlDataAdapter(“SELECT * FROM names”, conn);

DataSet ds = new DataSet();
ad.Fill(ds);

gvName.DataSource = ds;
gvName.DataBind(); //gvName is Gridview
}

protected void timer1_tick(object sender, EventArgs e)
{
BindGridView()
up1.Update(); //up1 is updatepanel object.
}

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>