<asp:DropDownList ID="ddlView" runat="server"
onselectedindexchanged="ddlView_SelectedIndexChanged" AutoPostBack="true">
<asp:ListItem Value="Select" Text="Select.."></asp:ListItem>
<asp:ListItem Value="FirstGrid" Text="First Grid"></asp:ListItem>
<asp:ListItem Value="SecondGrid" Text="Second Grid"></asp:ListItem>
<asp:ListItem Value="ThirdGrid" Text="Third Grid"></asp:ListItem>
</asp:DropDownList>
<asp:GridView ID="gvFirst" runat="server">
</asp:GridView>
<asp:GridView ID="gvSecond" runat="server">
</asp:GridView>
<asp:GridView ID="gvThird" runat="server"></asp:GridView>
Code Behind is
protected void ddlView_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlView.SelectedValue.ToString() == "Select")
{
gvFirst.DataSource = null;
gvFirst.DataBind();
gvSecond.DataSource = null;
gvSecond.DataBind();
gvThird.DataSource = null;
gvThird.DataBind();
}
else if (ddlView.SelectedValue.ToString() == "FirstGrid")
{
DataTable table = new DataTable();
table.Columns.Add("Selection", typeof(string));
table.Rows.Add("First Grid");
gvFirst.DataSource = table;
gvFirst.DataBind();
gvSecond.DataSource = null;
gvSecond.DataBind();
gvThird.DataSource = null;
gvThird.DataBind();
}
else if (ddlView.SelectedValue.ToString() == "SecondGrid")
{
DataTable table = new DataTable();
table.Columns.Add("Selection", typeof(string));
table.Rows.Add("Second Grid");
gvSecond.DataSource = table;
gvSecond.DataBind();
gvFirst.DataSource = null;
gvFirst.DataBind();
gvThird.DataSource = null;
gvThird.DataBind();
}
else
{
DataTable table = new DataTable();
table.Columns.Add("Selection", typeof(string));
table.Rows.Add("Third Grid");
gvThird.DataSource = table;
gvThird.DataBind();
gvFirst.DataSource = null;
gvFirst.DataBind();
gvSecond.DataSource = null;
gvSecond.DataBind();
}
}