ここでは例です:
ページでは:
の背後にあるコードで
<asp:DropDownList id="drp"
runat="server">
<asp:ListItem Value="GridViewDataSource1">Name 1</asp:ListItem>
<asp:ListItem Value="GridViewDataSource2">Name 2</asp:ListItem>
<asp:ListItem Value="GridViewDataSource3">Name 3</asp:ListItem>
</asp:DropDownList>
<asp:sqldatasource id="GridViewDataSource1" selectcommand="SELECT .. FROM .. " connectionstring="..." runat="server"/>
<asp:sqldatasource id="GridViewDataSource2" selectcommand="SELECT .. FROM .. " connectionstring="..." runat="server"/>
<asp:sqldatasource id="GridViewDataSource3" selectcommand="SELECT .. FROM .. " connectionstring="..." runat="server"/>
:
void button_click(Object sender, EventArgs e)
{
string SourceName = drp.SelectedValue;
gdvCars.DataSourceID = SourceName;
gdvCars.DataBind();
}