I have a grid and dropdownlist. I want to filter values in a grid by the selection of the dropdownlist.
My code is like this
<asp:DropDownList ID="DDLVisitedVol" runat="server" AutoPostBack="true" DataSourceID="DsVisitedVol"
DataTextField="VisitedVol" DataValueField="VisitedVol"
Width="244px">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString=""
ProviderName=""
SelectCommand="SELECT [ID],[UserName], [Email], [visitedVol] FROM [HitTracker] where visitedVol=@VisitedVol ">
<SelectParameters>
<asp:Parameter Name="VisitedVol" Type="String"/>
</SelectParameters>
</asp:SqlDataSource>
How can I pass the selected value of the dropdownlist to @VisitedVol?
Use ControlParameter:
<asp:ControlParameter ControlID="DDLVisitedVol" Name="VisitedVol" PropertyName="SelectedValue" Type="String"/>
The ControlParameter is your friend:
<asp:ControlParameter Name="VisitedVol" ControlID="DDLVisitedVol" PropertyName="SelectedValue"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With