Reputation: 11042
I have to load the data in asp:grid
after filtering from two asp:dropdown
list. For example following is the dropdown lists:
<asp:DropDownList ID="ddlb" runat="server" AutoPostBack="True"
CssClass="ddlb" Width="100px" DataSourceID="SqlDataSource3"
DataTextField="MonthYearName" DataValueField="MonthYear"
onselectedindexchanged="Changed">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:ProdDB %>" SelectCommand="# some sql query">
</asp:SqlDataSource>
<asp:DropDownList ID="asd" runat="server" AutoPostBack="True"
CssClass="ddlb" Width="100px" DataSourceID="SqlDataSource4"
DataTextField="MonthYearName" DataValueField="MonthYear"
onselectedindexchanged="SelectedIndexChanged">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource4" runat="server"
ConnectionString="<%$ ConnectionStrings:ProdDB %>" SelectCommand="# some queries">
</asp:SqlDataSource>
Now, When i am loading the page. It shows the above defined dropdown list. What i want to know is "how should i load the data in aspx grid
using the above two dropdown filter ?".
For example i choose A
option from the first dropdown then it filter the result on the basis of it and the data will display on grid
and so on...
Please tell me how should i connect the grid with these two dropdown list ?
How should i filter it ?
Upvotes: 0
Views: 388
Reputation: 17354
Place a grid and two drop down on the page. Place an SQL Data Source
Provide two parameters to the sql datasource select command
Attached that sqldatasource to the gridview
Bind the two parameters of the SQLDataSource to the the two Dropdown boxes.
Upvotes: 1