BusinesDataListWebPart Bug with Multiple Filter Rows

Using the BDC and the BDC List Webpart, works out well except where you try to add multiple filter rows after having done a postback (Retrieve Data) where there was previously more than 1 filter row. What happens is you get an unhelpful “An unexpected error has occurred”, if you disable Sharepoint custom errors, you get the rather more helpful exception information; 


Server Error in ‘/’ Application.

Input string was not in a correct format. 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: Input string was not in a correct format.
Source Error:


An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[FormatException: Input string was not in a correct format.] System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2751827 System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +102 System.Int32.Parse(String s, IFormatProvider provider) +22 Microsoft.SharePoint.Portal.WebControls.Filter.FromEncoded(String encodedName, String encodedOp, String value) +221 Microsoft.SharePoint.Portal.WebControls.BusinessDataListWebPart.filterFindButton_Click(Object objSender, EventArgs ea) +894 Microsoft.SharePoint.Portal.WebControls.PostbackLink.OnClick() +59 Microsoft.SharePoint.Portal.WebControls.PostbackLink.RaisePostBackEvent(String eventArgument) +54 Microsoft.SharePoint.Portal.WebControls.PostbackLink.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102     

After doing some digging with reflector, I believe I’ve tracked it down to a bug in the client side script rendered by the BusinesDataListWebPart in it’s GetQueryTableScripts() method.

This script declares a variable called BDList_lastRowIndex to 0 and which gets incremented each time you “Add” a filter condition in the webpart. This works out ok if you add your filter conditions prior to doing a postback (Retrieve Data). If you have say 2 filter conditions, do a postback (Retrieve Data), then add another filter condition and postback (Retrieve Data) you will get this error condition.

Using fiddler you can see that the filter rows have names like {ctlid}$BdwpFilterName0, {ctlid}$BdwpFilterName1, {ctlid}$BdwpFilterName2 etc, after a postback, adding new filter rows causes these new filters to be named from {ctlid}$BdwpFilterName1 onwards, even though, say, there may be 2 existing filter rows.

Sadly I don’t have a solution!

Published by

Phil Harding

SharePoint Consultant, Developer, Father, Husband and Climber.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.