Hi ghonadr,
You need to place the GridView panel inside the update panel or inside another update panel.
Refer below sample.
HTML
<asp:UpdateProgress ID="updateProgress" runat="server" DynamicLayout="true">
<ProgressTemplate>
<div style="position: fixed; top: 0px; bottom: 0px; left: 0px; right: 0px; overflow: hidden; padding: 0; margin: 0; background-color: #F0F0F0; filter: alpha(opacity=50); opacity: 0.5; z-index: 100000;"></div>
<div style="position: fixed; top: 50%; left: 35%; height: 20%; width: 20%; z-index: 100001; background-repeat: no-repeat; background-position: center;">
<img alt="" src="Images/Gif/loading5.gif" style="height: 128px; width: 128px;" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table style="width: 100%">
<tr>
<td style="width: 20%">المقر الدراسي</td>
<td style="width: 75%">
<asp:DropDownList ID="ddlCountries" runat="server">
<asp:ListItem Text="All" Value="0"></asp:ListItem>
<asp:ListItem Text="Argentina" Value="Argentina"></asp:ListItem>
<asp:ListItem Text="Austria" Value="Austria"></asp:ListItem>
<asp:ListItem Text="Belgium" Value="Belgium"></asp:ListItem>
<asp:ListItem Text="Brazil" Value="Brazil"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td style="width: 20%"></td>
<td style="width: 75%">
<asp:Button ID="btn_search" CssClass="btn btn-outline-blue" Width="300px" Height="45px" runat="server" Text="بحث" OnClick="btn_search_Click" />
</td>
<td style="width: 5%"></td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server">
<hr />
<asp:GridView ID="gv1" runat="server" AutoGenerateColumns="False" CssClass="mygrdContent grid" PagerStyle-CssClass="pager" HeaderStyle-CssClass="header" RowStyle-CssClass="rows" Width="100%">
<Columns>
<asp:BoundField DataField="CustomerID" HeaderText="الرقم الاكاديمي">
<ItemStyle Font-Size="12pt" />
</asp:BoundField>
<asp:BoundField DataField="ContactName" HeaderText="اسم الطالب">
<ItemStyle Font-Size="12pt" />
</asp:BoundField>
<asp:BoundField DataField="Address" HeaderText="المقر">
<ItemStyle Font-Size="12pt" />
</asp:BoundField>
<asp:BoundField DataField="City" HeaderText="التخصص">
<ItemStyle Font-Size="12pt" />
</asp:BoundField>
<asp:BoundField DataField="Country" HeaderText="الحالة الاكاديمية" />
<asp:BoundField DataField="Fax" HeaderText="الساعات المتبقية" />
</Columns>
<HeaderStyle CssClass="header"></HeaderStyle>
<PagerStyle CssClass="pager"></PagerStyle>
<RowStyle CssClass="rows"></RowStyle>
</asp:GridView>
<hr />
<asp:GridView ID="gv2" runat="server" AutoGenerateColumns="False" CssClass="mygrdContent grid" PagerStyle-CssClass="pager" HeaderStyle-CssClass="header" RowStyle-CssClass="rows" Width="100%">
<Columns>
<asp:BoundField DataField="CustomerID" HeaderText="الرقم الاكاديمي">
<ItemStyle Font-Size="12pt" />
</asp:BoundField>
<asp:BoundField DataField="ContactName" HeaderText="اسم الطالب">
<ItemStyle Font-Size="12pt" />
</asp:BoundField>
<asp:BoundField DataField="Address" HeaderText="المقر">
<ItemStyle Font-Size="12pt" />
</asp:BoundField>
<asp:BoundField DataField="City" HeaderText="التخصص">
<ItemStyle Font-Size="12pt" />
</asp:BoundField>
<asp:BoundField DataField="Country" HeaderText="كود المقرر">
<ItemStyle Font-Size="12pt" />
</asp:BoundField>
</Columns>
<HeaderStyle CssClass="header"></HeaderStyle>
<PagerStyle CssClass="pager"></PagerStyle>
<RowStyle CssClass="rows"></RowStyle>
</asp:GridView>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
Namespaces
C#
using System.Data;
using System.Data.SqlClient;
VB.Net
Imports System.Data
Imports System.Data.SqlClient
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
BindGridView("");
}
}
private void BindGridView(string country)
{
System.Threading.Thread.Sleep(2000);
string constr = @"Data Source=.;Initial Catalog=Northwind;integrated security=true";
using (SqlConnection con = new SqlConnection(constr))
{
string query = "SELECT * FROM Customers WHERE Country = @Country OR @Country IS NULL";
using (SqlCommand cmd = new SqlCommand(query))
{
cmd.Connection = con;
cmd.Parameters.AddWithValue("@Country", !string.IsNullOrEmpty(country) ? country : (object)DBNull.Value);
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(dt);
gv1.DataSource = dt;
gv1.DataBind();
gv2.DataSource = dt;
gv2.DataBind();
}
}
}
protected void btn_search_Click(object sender, EventArgs e)
{
if (ddlCountries.SelectedValue == "0")
{
BindGridView("");
}
else
{
BindGridView(ddlCountries.SelectedValue);
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not Me.IsPostBack Then
BindGridView("")
End If
End Sub
Private Sub BindGridView(ByVal country As String)
System.Threading.Thread.Sleep(2000)
Dim constr As String = "Data Source=.;Initial Catalog=Northwind;integrated security=true"
Using con As SqlConnection = New SqlConnection(constr)
Dim query As String = "SELECT * FROM Customers WHERE Country = @Country OR @Country IS NULL"
Using cmd As SqlCommand = New SqlCommand(query)
cmd.Connection = con
cmd.Parameters.AddWithValue("@Country", If(Not String.IsNullOrEmpty(country), country, CObj(DBNull.Value)))
Dim dt As DataTable = New DataTable()
Dim sda As SqlDataAdapter = New SqlDataAdapter(cmd)
sda.Fill(dt)
gv1.DataSource = dt
gv1.DataBind()
gv2.DataSource = dt
gv2.DataBind()
End Using
End Using
End Sub
Protected Sub btn_search_Click(ByVal sender As Object, ByVal e As EventArgs)
If ddlCountries.SelectedValue = "0" Then
BindGridView("")
Else
BindGridView(ddlCountries.SelectedValue)
End If
End Sub