Hi @Manoj Gokhale
You can use asp:ScriptManager, asp:UpdatePanel, and asp:Timer to achieve automatic partially refresh.
Since asp:ScriptManager, asp:UpdatePanel can implement partial scripting functions. At the same time<asp:timer> can realize the function of performing an operation at a regular time. This enables the ability to partially refresh data (without requiring the user to submit a request).
Code:
<body>
<form id="form1" runat="server">
<b>Test</b>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="updPanel" runat="server">
<ContentTemplate>
<asp:Timer ID="timerTest" runat="server" Interval="2000" OnTick="Timer1_Tick">
</asp:Timer>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ appSettings:ConnStr %>" SelectCommand="select Name,Age from dbo.Test">
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="Age" HeaderText="Age" SortExpression="Age" />
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs)
GridView1.DataBind()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Output:
Best regards,
Qi You
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.