locked
filter sqldatabase using dropdown list control RRS feed

  • Question

  • User1707590764 posted

    Hi!

    i wanit to create a page where i have an sql database  source control and the data displayed using formview/gridview or listview control.

    I then want one datafield to be replaced by a dropdown list and filter the data displayed in the page correspondingly being filtered as per the selected list.

    For example i have a library database table with author, genre and title as columns. i then want to have a dropdown list for  filtering the database view as per dropdown list selection. Say, ihave the genre mapped to the dropdwn list and as per my selection of genre only those books are shown in the databe view.

    Can anyone help?

    Tuesday, January 4, 2011 12:06 PM

Answers

  • User626880745 posted

    I then want one datafield to be replaced by a dropdown list and filter the data displayed in the page correspondingly being filtered as per the selected list.

    Keep that DropDownList outside the DataBound control whether ListView/GridView/FormView (FormView would display one record at a time); provide the DDL with its own data source.

    and use a ControlParameter within the SelectParameters of the SqlDataSource. refer the example here: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.selectparameters.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 4, 2011 12:59 PM