Showing posts with label moss. Show all posts
Showing posts with label moss. Show all posts

Tuesday, March 10, 2009

How to determine if your webpart is providing for others

In my continuation with my webpart for connecting two SPGridViews together I came across the need to determine if the current instance of the part was actually providing for any other webparts. The reason I need to know this is because I wanted to render the first column as a select link if it was providing to another part, but otherwise just render as a standard datacolumn.

Here is the solution I came up with:

 Private Function IsProviding() As Boolean
For Each c As WebPartConnection In Me.WebPartManager.Connections
If c.Provider Is Me Then
Return True
End If
Next
Return False
End Function
Does anyone have another way to determine this?
 



Configuring a SharePoint WebPart as both a Consumer and Provider for the same interface

Recently I’ve been coding a web part that shows a sql query inside a SPGridView and wanted to set it up so it could be a connection provider (ConnectionProvider) as well as a connection consumer (ConnectionConsumer).

For some reason, when I set it up this way the Connections menu used to configure the inbound and outbound connections was greyed out when I had both, but worked if I commented out either one.

It seems that there is an optional argument named “id” for both the ConnectionProvider and ConnectionConsumer decorators and when I provided this argument it started working. It seems there is a default id if you don’t specify it and they must have the same default id.

My code now looks something like this:

#Region "IWebPartRow Provider"
<ConnectionProvider("RowProvider", "DataViewRowProvider")> _
Public Function GetConnectionInterface() As IWebPartRow
Return New DataViewWebPart()
End Function

Public Sub GetRowData(ByVal callback As RowCallback) _
Implements IWebPartRow.GetRowData
callback(oGrid.SelectedRow)

End Sub

Public ReadOnly Property Schema() As _
ComponentModel.PropertyDescriptorCollection Implements IWebPartRow.Schema
Get
Return TypeDescriptor.GetProperties(oView)
End Get
End Property
#End Region
#Region "IWebPartRow Consumer"
<ConnectionConsumer("Row", "DataViewRowConsumer")> _
Public Sub SetConnectionInterface(ByVal provider As IWebPartRow)
_provider = provider
End Sub

#End Region

Wednesday, October 1, 2008

Clever Workarounds

I just came across this nice collection of SharePoint resources from Paul Culmsee. It includes SharePoint Branding, Project Management and Return on Investment for SharePoint.

Thursday, July 17, 2008

What to do if you've buggered your SharePoint page

Run your page with the contents=1 query and it will take you into a page that will allow you to delete parts from your page and save it.

http://yoursharepointsite.com/default.aspx?contents=1

Thursday, June 19, 2008

Custom Web Properties Not Showing in MOSS 2007

http://ph-tom.blogspot.com/2008/02/custom-web-part-properties-not-showing.html

Some SharePoint lessons for beginning developers

http://blogs.charteris.com/blogs/edwardw/archive/2007/07/02/sharepoint-web-part-development-lessons-learnt.aspx

Error 1 - Deploying a WebPart solution

Problem:
Error 1 The solution can not be deployed. Directory "DataView" associated with feature 'ad6ebc94-517f-4653-be15-84ceb207f5ec' in the solution is used by feature '99088a73-c387-4c4b-94be-a73353a270da' installed in the farm. All features must have unique directories to avoid overwriting files.

Solution:
Go into Central Administration, Operations, Solution Management and retract the solution.

I had this problem when using the VS2005 SharePoint Extensions after I deployed a solution the first time, changed the solution and then tried to deploy it again. I'm not sure why I had the problem, I would think I could edit and redeploy again and again.

Web Part Gallery Groups

How to add a group designation before you import your webpart into the SharePoint Gallery.

http://blog.maskar.net/2007/06/wss-30-web-part-gallery-groups_14.html