Monday, October 18, 2010

Pass external values with GridView HyperLinkField which are not part of the Gridview

As long as you only could use data sources members in NavigateUrl of GridView, I use this way to pass external values with GridView HyperLinkField which are not part of the Gridview :
For example I've an
_ID1 (a member of GridView) , _ID2(External data with sample value 100 as string), which should pass to my NavigateUrl, simply :

1. Define "protected string _ID = "100";" at top of class.
2. NavigateUrl=''
3. You are done.

Monday, January 18, 2010

BDC Import error: Could not create profile page for Entity

In SharePoint While you import the BDC (XML) file you may get this error:
"Could not create profile page for Entity 'xxx'.The error is: Cannot create a new connection to closed Web Part 'x-y-z' "
After 2 days searching with no practical solution I decide to solve it by myself by monitoring SQL and Web Parts underground, finally I've found and solved the solution.It worked to me 100%.
What is the error exactly?
While you create a specific finder for the BDC to profile it, (so "could not create profile..." warning solve by the way) then you may get the above error because one of the following reasons which I've found (you should do step by step in my order to get faster response):
Problem 1: You might close "Profile Page Template Web Part", when a BDC want to associate a profile to a template page it returns and error that : "Cannot create a new connection to closed Web Part".
Solution 1:
1. Go to the "Shared Services" admin page.
2. Under "Business Data Catalog" click on "Edit profile page template".
3. If you don't see the "Business Data Item" Web Part in the page go to Step 4 , otherwise go to Problem 2 .
4. Navigate to Site Actions->Edit Page then click on "Add a Web Part", this will open a page.
5. On the opened "Add Web Part to Top Zone" page, click on "Advanced Web Part gallery and options".
6. On the "Add Web Parts", click on "Closed Web Part" and select "Business Data Item" and drag to the page to restore it.
7. click "Exit Edit Mode" (on top right).
8. You done.So back to the BDC import page and import the BDC.
Problem 2: Check Problem 1 first.Do not waste your time. If did so, your problem is you closed a web part in which may did not remove from SQL correctly.
Solution 2:
1. I've coded a TSQL to solve faster and safe, so copy the uniqueidentifier for the close web part from the error message, for example mark and copy the bold section:
"The error is: Cannot create a new connection to closed Web Part g_38004421_f6ad_4880_807a_8c90bcf42f4a "
note that I do not mark and copy "g_".
2. open SQL management studio and query this script. Replace the bold parameters with yours:
USE WSS_Content
DECLARE @Id nvarchar(50)
DECLARE @WId nvarchar(50)
SELECT @WId = 'UNIQUEIDENTIFIER '
SELECT @Id =(
SELECT id FROM AllDocs
WHERE id =(
SELECT tp_PageUrlID FROM WebParts
WHERE tp_id like '%' + @WId + '%' ))
DELETE FROM WebParts
WHERE tp_PageUrlID like '%' + @Id + '%'
DELETE FROM AllDocs
WHERE id like '%' + @Id + '%'
The code above find the UID that cause the error in the WebParts table and AllDocs related object, then delete them.
All works to me. Hope you too.

Sunday, January 17, 2010

SharePoint WebPart Tips and Tricks

To view and manage all Web Parts within a page or see the status of them, simply append "?contents=1" to a given URL page. for example:
http://vsmoss/sites/intranet/some_reports.aspx
would be:
http://vsmoss/sites/intranet/some_reports.aspx?contents=1
brings you to the Web Part Page Maintenance Some_Reports
There was an error in this gadget