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

How to bind a ComboBox in a DetailView Template in C#


is it possible to bind a ComboBoxAdv in DetailView Template of a SfDataGrid with C#?


1 Reply

DY Deivaselvan Y Syncfusion Team November 8, 2018 06:17 AM UTC

Hi Patrick, 

Thank you for contacting Syncfusion support. 

We have analyzed your query “To bind ComboBoxAdv in DetailsViewTemplate with C#”. You can achieve your requirement by using the below code snippet 

public class SfDataGridBehavior: Behavior<SfDataGrid> 
        protected override void OnAttached() 
            TemplateViewDefinition templateViewDefinition = new TemplateViewDefinition(); 
            templateViewDefinition.RowTemplate = GetDataTemplate(); 
        private DataTemplate GetDataTemplate() 
            FrameworkElementFactory comboBoxAdv = new FrameworkElementFactory(typeof(ComboBoxAdv)); 
            comboBoxAdv.SetValue(ComboBoxAdv.HorizontalAlignmentProperty, HorizontalAlignment.Center); 
            comboBoxAdv.SetValue(ComboBoxAdv.VerticalAlignmentProperty, VerticalAlignment.Center); 
            comboBoxAdv.SetValue(ComboBoxAdv.SelectedValueProperty, "ProductName"); 
            comboBoxAdv.SetValue(ComboBoxAdv.DisplayMemberPathProperty, "ProductName"); 
           comboBoxAdv.SetValue(ComboBoxAdv.WidthProperty, 200d); 
            Binding binding = new Binding(); 
            binding.Path = new PropertyPath("DataContext.OrderList"); 
            binding.ElementName = this.AssociatedObject.Name; 
            comboBoxAdv.SetBinding(ComboBoxAdv.ItemsSourceProperty, binding);  
            var dataTemplate = new DataTemplate() { VisualTree = comboBoxAdv }; 
            return dataTemplate; 

Please find sample for the same from below link and let us know if this helps you. 


Live Chat Icon For mobile
Up arrow icon