Just add Update panel for GridView no need to add Update panel for Textbox and button which is Outside of GridView else it will raise same problem of losing cursor focus from the controls.
Refer the below sample for your reference.
HTML
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
Name: <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:Button ID="btnDisplay" runat="server" OnClick="Display" Text="Display" />
<br />
<asp:Label ID="lblname" runat="server"></asp:Label>
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" OnTick="RefreshGridView" Interval="1000" />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="CustomerId" HeaderText="Id" />
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="Country" HeaderText="Country" />
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
C#
protected void Display(object sender, EventArgs e)
{
//Your other action here i just showing Textbox value to label control
lblname.Text = txtName.Text;
}
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
BindGridView();
}
}
private void BindGridView()
{
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConStr"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT * FROM CustomerTest";
con.Open();
GridView1.DataSource = cmd.ExecuteReader();
GridView1.DataBind();
con.Close();
}
}
}
protected void RefreshGridView(object sender, EventArgs e)
{
BindGridView();
}
VB.Net
Protected Sub Display(sender As Object, e As EventArgs) Handles Me.Load
'Your other action here i just showing Textbox value to label control
lblname.Text = txtName.Text
End Sub
Protected Sub Page_Load(sender As Object, e As EventArgs)
If Not Me.IsPostBack Then
BindGridView()
End If
End Sub
Private Sub BindGridView()
Using con As New SqlConnection(ConfigurationManager.ConnectionStrings("ConStr").ConnectionString)
Using cmd As New SqlCommand()
cmd.Connection = con
cmd.CommandType = CommandType.Text
cmd.CommandText = "SELECT * FROM CustomerTest"
con.Open()
GridView1.DataSource = cmd.ExecuteReader()
GridView1.DataBind()
con.Close()
End Using
End Using
End Sub
Protected Sub RefreshGridView(sender As Object, e As EventArgs)
BindGridView()
End Sub
At same time we executed insert statement in backend to check the OnTick refresh functionality which gets call after Interval period sets in Timer.
SQL
INSERT INTO [CustomerTest]([CustomerId],[Name],[Country])
VALUES(4,'Robert Schidner','Russia')
GO
Screenshot