User1577371250 posted
Hi,
1. Add a DropDownList with the items, Set AutoPostBack="True" and Add the SelectIndexChange Event
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" Width="61px">
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>b</asp:ListItem>
<asp:ListItem>c</asp:ListItem>
</asp:DropDownList>
<asp:GridView ID="GridView1" runat="server"></asp:GridView>
2. Write the Code in Page
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Construct the query with the required COLUMNS
// get the Data From Table1 and Bind the GridView
GridView1.DataSource = "";
GridView1.DataBind();
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedValue == "a")
{
// Construct the query with the required COLUMNS
// get the Data From Table1 and Bind the GridView
GridView1.DataSource = "";
GridView1.DataBind();
}
if (DropDownList1.SelectedValue == "b")
{
// get the Data From Table2 and Bind the GridView
GridView1.DataSource = "";
GridView1.DataBind();
}
if (DropDownList1.SelectedValue == "c")
{
// get the Data From Table3 and Bind the GridView
GridView1.DataSource = "";
GridView1.DataBind();
}
}