Microsoft KB Archive/316320

= You cannot use a custom expression in the DisplayMember property of a bound control =

Article ID: 316320

Article Last Modified on 3/9/2006

-

APPLIES TO


 * Microsoft ADO.NET 1.1
 * Microsoft ADO.NET 1.0
 * Microsoft ADO.NET 2.0

-



This article was previously published under Q316320



SYMPTOMS
If you try to use a custom expression for the value of the DisplayMember property of a bound control, the combo box does not accept any input other than a valid field name from the data source.



RESOLUTION
If you want to display more than one field as a single unit, or if you want to display any other calculated field as the DisplayMember property of a bound control, you must modify your SELECT statement so that it includes an expression column in the DataSet object.



STATUS
This behavior is by design.



Steps to Reproduce the Behavior
 Start Microsoft Visual Studio .NET. Create a new Windows Application project in Visual Basic .NET. Form1 is added to the project by default. In the Server Explorer window, right-click Data Connections, and then click Add Connection. In the Data Link Properties dialog box, add the required data to add a data connection that connects to the Pubs database in a server that is running Microsoft SQL Server. Expand the nodes in the Data Connections tree to locate the Authors table. Drag the Authors table from the Server Explorer window to Form1.</li> Click in Form1. In the Properties window, click Generate Dataset, and then click OK in the Generate Dataset dialog box to accept the default values.</li> Add a ComboBox control to Form1, and then set the DataSource property of the ComboBox to DataSet11.Authors.</li> In the DisplayMember list, click au_lname.</li>  Try to change the value of the DisplayMember property to the following expression: au_lname & &quot;, &quot; & au_fname Notice that the value that you try to use is overwritten by au_lname, as if your custom expression in not a valid field name. </li></ol>

Additional query words: columns multi-columns multicolumns type

Keywords: kbdatabinding kbprb KB316320

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.