Filtering Data Views with ASP Controls
In the previous post I talked about filtering data views with URL parameters. In this post I will deal with filtering the data with ASP.Net controls.
Tip – You can’t insert the control when you point on a web part zone; You can add <br> tag under a web part zone and add the control there.
Here are the steps:
Right-click on the list/library that will supply the values for the control in the Data source library panel. Chose the second option “Insert source data control”. If your prompted to turn on “Visual Aid” click yes. SPDataSource was added to your page.
In the top menu chose Insert > ASP.NET controls > Drop down list, an ASP control was added to your page. Click on the small arrow next to the control, from the Common DropDownList Task menu click Chose Data Source… and then chose spdatasource1, fill in the other fields as shown in the example(In this example I would like to filter according to the title). Click OK and Check Enable Auto Post Back.
Now add your data view (1). Click on the small arrow of the data view, from the Common Data View Task menu chose Filter (2). In the Field Name choose the field that you want to filter by (Document type for this example), in the Value field chose Create new parameter (3).
In the Data view Parameters window, under Parameters source filed chose Control. In Control ID filed chose you control ID (probably DropDownList1),You can add default value. Click Ok and Ok.
5. Save you page and view it in the browser.
– if you reattach you page to layout the control will be lost. The reason is that we broke the connection to the layout when we placed the asp control outside the web part zone.