Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've got a Data Form Web Part in SharePoint 2010 Designer that I'd like to customize so users can filter it on one of the columns. In other words, they'd be able to drop the web part in, then choose "Edit Web Part" from the down arrow, and then in the properties dialog, go to the Miscellaneous tab. There, you'd have a field labeled "Filter:" and the user would enter a text to filter the list used in the web part.

Is this possible? Any example? Thanks.

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

You would need to create your own subclass the DataFormWebPart. Once that is done, you can expose simple text properties by adding attributes like these to the WebPart property that you wish the user to be able to change.

[WebBrowsable,
WebDisplayName("User name"),
WebDescription("The Full Username"),
Category("SomeCategory"),
Personalizable(PersonalizationScope.Shared)]

However, if you are looking to go for anything more advanced then you will need to look into creating your own custom ToolPart. More detailed instructions are available at: http://www.wictorwilen.se/Post/Web-Part-Properties-part-1-introduction.aspx

share|improve this answer
    
Thanks, Dave. This is very helpful. How does the web part read the custom properties? For example, if we have a Filter field, how do we read and pass that to our DataFormWebPart? –  Alex C Jul 19 '11 at 5:46
    
I'm no expert on the DataFormWebPart but my guess would be that you would have to override the .FilterField and .FilterValue properties in your subclass and then have them return the Field/Value that you wish to apply the user filtering against. –  Dave Wise Jul 19 '11 at 16:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.