You must Sign In to post a response.
  • Category: ASP.NET

    Auto Refresh Gridview in asp.net

    i am having a gridview , which should be auto refreshed on every 5 min or postback from other page.
  • #769294
    [Response removed by Admin. Read forum policies.]

  • #769332
    Hi Md Nadeem,

    1.) If you are binding grid in code behind , then u can use timer control of asp.net and on timer elapsed function call you can rebind the grid


    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick">
    </asp:Timer>

    <GRID>

    </ContentTemplate>
    </asp:UpdatePanel>

    protected void Timer1_Tick(object sender, EventArgs e)
    {
    //Grid.BIND()
    }


    2.) If u are binding the grid on client side then u can invoke SetInetrval function and rebind the grid there.

    ~Cheers!!

    Thanks!
    Anjali Bansal

    ~Give your best and lead the world

  • #769374
    Hi,


    <asp:ScriptManager ID="SCManager1" runat="server"></asp:ScriptManager>

    <asp:Timer ID="Time1" runat="server" Interval="500" OnTick="Timer1_TimerClick"></asp:Timer>
    <asp:UpdatePanel runat="server">
    <ContentTemplate>
    <asp:GridView ID="Gridview1" runat="server"></asp:GridView>
    </ContentTemplate>
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="Time1" EventName="TimerClick" />

    </Triggers>

    </asp:UpdatePanel>


    CodeBehind:

    protected void TimerClick(object sender, EventArgs e)
    {
    Gridbinding()

    }
    public void Gridbinding()
    {
    sqlQuery = "SELECT * FROM Table1"
    Gridview1.DataSource = con.ReturnQuery(sqlQuery );
    Gridview1.DataBind();
    }


  • Sign In to post your comments