We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

MultiColumnDropDownCombo Question

I would like to make use of the MultiColumnDropDownCombo control for a variety of different "pick lists" within my application. For example, assume I have a Customers table with the following columns:

CustomerID GUID, Primary Key
CompanyName varchar(50)
City varchar(20)

I want to display a drop-down combo box that shows columns "CompanyName" and "City", but does not display the "CustomerID". When a selection is made, the text displayed in the control should be the CustomerName.Value.

Upon postback, I need to be able to query the "CustomerID" value associated with the selection in order to proceed with further processing.

I've struggled to find a way to make this work. It appears that the controls "DataKeyField" property is used to specify the displayed text, but there is no complementary property to specify the "CustomerID" as the selection value.

Also, if "AutoGenerateColumns" is set to true, then of course all columns in the data source are displayed. However, if set AutoGenerate... to false, then there is no obvious way to manually create the columns, and nothing within the documentation to help.

I thought I could add the columns at runtime in the Page_Load() event, but the Control.Columns collection expects to receive a DataGridColumn object, which cannot be instantiated because it has a protected constructor.

How does one accomplish this?

3 Replies

MW Melba Winshia Syncfusion Team July 1, 2009 10:17 AM UTC

Hi John,

Thank you for your interest in Syncfusion Products.

You can manually define the column fields by setting the AutoGenerateColumns property to false and then creating a custom Columns collection. Please refer below code snippet to achieve this:

DataSourceID="AccessDataSource1" DataTextFormatField="{LastName} ({FirstName})"
PopupHeight="229px" PopupWidth="630px">




<%# DataBinder.Eval(Container, "DataItem.EmployeeID")%>





<%# DataBinder.Eval(Container, "DataItem.LastName")%>





<%# DataBinder.Eval(Container, "DataItem.FirstName")%>





<%# DataBinder.Eval(Container, "DataItem.HomePhone")%>







Please refer the sample in the below link which illustrates the above:

http://files.syncfusion.com/samples/Tools.Web/7.2.0.37/84475_MultiColumn/main.htm

Please try this and let me know if this helps.

Thanks,
Melba


AD Administrator Syncfusion Team July 6, 2009 03:45 PM UTC

Hello Melba,

Thank you for the example. When I try this method, data binding no longer seems to work. The control will not display any data. Here is the code I am using:

ID="mailToDropDownBox"
runat="server"
Width="380px"
AutoFormat="Vista"
DataSourceID="mailRecipientsSource"
DataKeyField="Display_Name"
ShowHeader="False"
AutoGenerateColumns="False"
PopupWidth="400px"
ClientSideOnSelectedIndexChange="OnSelectedIndex(this)"
ClientSideOnTextChanged="OnTextChange(this)">



HeaderText="Display_Name">

<%# DataBinder.Eval(Container,
"DataItem.Display_Name")%>





ID="mailRecipientsSource"
runat="server"
ConnectionString="<%$ ConnectionStrings:myConnStr %>"
SelectCommand="SELECT [Display_Name],
[Title],
[Member_Id]
FROM [vw_BoardVolunteers_Display_List]
WHERE ([Email_Published] IS NOT NULL)
ORDER BY [RoleType_SortOrder],
[Role_SortOrder],
[Display_Name]"
EnableCaching="True">


AD Administrator Syncfusion Team July 6, 2009 04:42 PM UTC

Never mind.. I can see where I didn't enclose the properly within the control.


Loader.
Live Chat Icon For mobile
Up arrow icon