You cannot use a custom expression in the DisplayMember property of a bound control (316320)



The information in this article applies to:

  • Microsoft ADO.NET (included with the .NET Framework 1.1)
  • Microsoft ADO.NET (included with the .NET Framework) 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.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Start Microsoft Visual Studio .NET.
  2. Create a new Windows Application project in Visual Basic .NET. Form1 is added to the project by default.
  3. In the Server Explorer window, right-click Data Connections, and then click Add Connection.
  4. 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.
  5. Expand the nodes in the Data Connections tree to locate the Authors table.
  6. Drag the Authors table from the Server Explorer window to Form1.
  7. 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.
  8. Add a ComboBox control to Form1, and then set the DataSource property of the ComboBox to DataSet11.Authors.
  9. In the DisplayMember list, click au_lname.
  10. Try to change the value of the DisplayMember property to the following expression:
    au_lname & ", " & 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.

Modification Type:MinorLast Reviewed:3/9/2006
Keywords:kbDataBinding kbprb KB316320 kbAudDeveloper