0

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.

1 Answer 1

4

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

2
  • 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, 2011 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, 2011 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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