Tuesday, October 28, 2008

PagerRow not showing in SPGridView when setting AllowPaging=true

When you enable paging in an SPGridView, the PagerRow doesn't show up by default. To work around this, you have to set the PagerTemplate to 'null' AFTER adding the control to the controls collection but BEFORE calling DataBind().

e.g.

protected override void CreateChildControls() {
SPGridView grid = new SPGridView;
grid.AllowPaging=true;
this.Controls.Add(grid);
//set PagerTemplate to null
grid.PagerTemplate = null;
grid.PageIndexChanging +=
new GridViewPageEventHandler(grid_PageIndexChanging);
grid.DataBind();
}

Friday, October 24, 2008

Showing the StackTrace in SharePoint

Instead of being stuck with the default errors in sharepoint (usually 'unexpected error'), you can force SharePoint to show the StackTrack.

To do so, you must make 2 changes to the web.config file of each site where you wish to enable this.

First of all, set the 'Mode' value of the 'CustomErrors' element to 'Off' (or 'RemoteOnly')

Second, set the 'CallStack' value for the 'SafeMode' element to 'true'

Thursday, October 23, 2008

Error 'SPSearch ([accountname]) when trying to activate WSS Search

I ran into the error shown below when I tried to activate WSS Search on my development server:  When examining the WSS Log file, I found the following error:

The call to SPSearchServiceInstance.Provision (server '[servername]') failed. Setting back to previous status 'Disabled'. System.ComponentModel.Win32Exception: SPSearch (mossadmin) at Microsoft.SharePoint.Win32.SPAdvApi32.ChangeServiceConfiguration(String strServiceName, String strAccountName, SecureString sstrPassword, IdentityType identityType, Boolean bDontRestartService) at Microsoft.SharePoint.Administration.SPProvisioningAssistant.ProvisionProcessIdentity(String strUserName, SecureString secStrPassword, IdentityType identityType, Boolean isAdminProcess, Boolean isWindowsService, String strServiceName, Boolean dontRestartService) at Microsoft.SharePoint.Administration.SPProcessIdentity.ProvisionInternal(SecureString sstrPassword, Boolean isRunningInTimer) at Microsoft.SharePoint.Administration.SPProcessIdentity.Provision() at Microsoft.SharePoint.Administration.SPWindowsServiceInstance.ProvisionCredentials() at Microsoft.SharePoint.Administration.SPWindowsServiceInstance.Provision(Boolean start) at Microsoft.SharePoint.Administration.SPWindowsServiceInstance.Provision() at Microsoft.SharePoint.Search.Administration.SPSearchServiceInstance.Provision() at Microsoft.SharePoint.Search.Internal.UI.SPSearchServiceInstanceSettings.BtnSubmit_Click(Object sender, EventArgs args)

After fiddeling around with the settings, I figured out that you must enter the name of the service and content accounts in the format [SERVERNAME]\[AccountName].