Wednesday, August 11, 2010

Retrieve webpart connection details programmatically using SPWebPartConnection

If you wish to retrieve the webpart information programmatically then you can use following function.


private void FindConnectedWebPart(SPLimitedWebPartManager wpm)
{
SPWebPartConnectionCollection webPartConColl = wpm.SPWebPartConnections;
try
{
foreach (SPWebPartConnection webPartCon in webPartConColl)
{
string strProviderTitle = RemoveSpecialCharacters(webPartCon.Provider.Title);
string strConsumerTitle = RemoveSpecialCharacters(webPartCon.Consumer.Title);
if (String.Compare(webPartCon.Provider.GetType().Name, "SPSlicerTextWebPart", true) == 0)
{
string strFilterName = ((Microsoft.SharePoint.Portal.WebControls.SPSlicerBaseWebPart)(webPartCon.Provider)).FilterName;
}
TransformableFilterValuesToFilterValuesTransformer transformerMapping = (TransformableFilterValuesToFilterValuesTransformer)webPartCon.Transformer;
// use these details as per your requirements
}
}
catch (Exception ex)
{
// exception detail
}

}


Thanks!
Avinash Dad

No comments: