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.
Unfortunately, activation email could not send to your email. Please try again.

MultiColumnDropDownCombo Question

Thread ID:

Created:

Updated:

Platform:

Replies:

84475 Jun 30,2009 08:58 PM Jul 6,2009 12:42 PM ASP.NET Web Forms (Classic) 3
loading
Tags: Tools
Administrator [Syncfusion]
Asked On June 30, 2009 08:58 PM

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?

Melba Winshia [Syncfusion]
Replied On July 1, 2009 06:17 AM

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

Administrator [Syncfusion]
Replied On July 6, 2009 11:45 AM

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">

Administrator [Syncfusion]
Replied On July 6, 2009 12:42 PM

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;