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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Bind visible column ComboBox to DataTable

Thread ID:

Created:

Updated:

Platform:

Replies:

99845 Jun 15,2011 01:44 PM UTC Jun 22,2011 07:25 PM UTC WPF 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On June 15, 2011 01:44 PM UTC

Hello,

In my GridDataControl I have a combobox type column which I would like to bind to a datatable.

I've tried this with no success:

var _eventTypes = from g in GlobalData.db.EventTypes select new { g.EventTypeID, g.EventTypeDesc };
DataTable dtEvents = new DataTable();
DataColumn column; DataColumn column2;
column = new DataColumn(); column2 = new DataColumn();

column.ColumnName = "EventTypeID";
column2.ColumnName ="EventTypeDesc";
column2.DataType = System.Type.GetType("System.String");
column.DataType = System.Type.GetType("System.Int32");
dtEvents.Columns.Add(column);
dtEvents.Columns.Add(column2);

foreach (var o in _eventTypes)
{
// dicEventType.Add(o.EventTypeDesc, o.EventTypeID);
DataRow row = dtEvents.NewRow();
row[0] = int.Parse(o.EventTypeID.ToString());
row[1] = o.EventTypeDesc;
dtEvents.Rows.Add(row);
}


int test = dtEvents.Rows.Count;

this.grdEventsUpload.VisibleColumns["EventType"].ColumnStyle.ItemsSource = dtEvents;
this.grdEventsUpload.VisibleColumns["EventType"].ColumnStyle.ValueMember = "EventTypeID";
this.grdEventsUpload.VisibleColumns["EventType"].ColumnStyle.DisplayMember = "EventTypeDesc";

I'm not getting any errors but the combobox items list is empty.

thanks



Deenadhayalan M [Syncfusion]
Replied On June 22, 2011 07:25 PM UTC

Hi Assaf,

Thanks for your interest in Syncfusion products.

We have prepared a sample based on your code snippet and achieved your requirement. Please find the sample under the following location.

Please let us know if this sample helps.

Regards,
Deenadhayalan



Combobox_Database_dadf61c0.zip

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.

Warning Icon 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.Close Icon

;