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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Two GridComboBoxColumn with different display member

Thread ID:

Created:

Updated:

Platform:

Replies:

148264 Oct 12,2019 10:32 AM UTC Oct 15,2019 12:58 PM UTC WinForms 3
loading
Tags: SfDataGrid
Riad
Asked On October 12, 2019 10:32 AM UTC

I have sfDataGrid bounded with a model and i have two GridComboBoxColumn with the same value member and different display member and when i add a new record it show the same value! how can i show the according display member for the second gridcomboboxcolumn?

//GridComboBoxColumn populating code
List<ProductModel> model = GlobalConfig.Connection.GetAllProducts(string.Empty, 0, 0);

//Product code
(this.gridViewPurchaseOrderDetail.Columns[3] as GridComboBoxColumn).DataSource = model;
(this.gridViewPurchaseOrderDetail.Columns[3] as GridComboBoxColumn).DisplayMember = "ProductCode";
(this.gridViewPurchaseOrderDetail.Columns[3] as GridComboBoxColumn).ValueMember = "ProductId";
//Description
(this.gridViewPurchaseOrderDetail.Columns[4] as GridComboBoxColumn).DataSource = model;
(this.gridViewPurchaseOrderDetail.Columns[4] as GridComboBoxColumn).DisplayMember = "Description";
(this.gridViewPurchaseOrderDetail.Columns[4] as GridComboBoxColumn).ValueMember = "ProductId";               

//Add a new record to the grid
var orderDetailModel = new OrderDetailModel
{
                OrderDetailId = 0,
                OrderId = _orderId,
                Quantity = 1,
                ProductId = selectedProduct.ProductId,
                UnitCost = selectedProduct.UnitCost,
                Tax = selectedProduct.Tax,
                TaxRate = GetTaxRateByName(selectedProduct.Tax)
};

var record = this.gridViewPurchaseOrderDetail.View.CreateRecordEntry(orderDetailModel);
this.gridViewPurchaseOrderDetail.View.Records.Add(record);

Attachment: Screenshot_ec3cd71c.rar

Gowtham Gopalsamy [Syncfusion]
Replied On October 14, 2019 12:27 PM UTC

Hi Riad   
    
Thank you for using Syncfusion controls.     
  
We have analyzed your query “To have two GridComboBoxColumn with the same value member and different display member and add the new value in the GridComboBoxColumn, the same value can be shown in both combobox column”. This is the behavior of the combobox column.   
  
Please let us know the reason why you are using same value member for the both GridComboBoxColumn? You can use the different datasource collection for GridComboBoxColumn.   
  
Please let us know, if you require further assistance on this.   
   
Regards,       
Gowtham     


Riad
Replied On October 14, 2019 11:12 PM UTC

Because i want to display the product code and description product on purchase order detail but i have just productId in order detail as foreign key of product table i tried that with devexpress component and it worked fine, is there a solution for that without adding a field to order detail table 

Gowtham Gopalsamy [Syncfusion]
Replied On October 15, 2019 12:58 PM UTC

Hi Riad,    
                                                                                                                           
Thanks for using Syncfusion controls.    
    
You can achieve your requirement to have two GridComboBoxColumn with the same value member and different display member and add the new value in the GridComboBoxColumn and you can set the different MappingName for GridComboBoxColumn.  
 
Please refer the below code snippet, 
 
 
this.sfDataGrid1.Columns.Add(new GridComboBoxColumn() { MappingName = "ShipCity", HeaderText = "Ship City", DisplayMember = "ShipCityName", ValueMember = "ShipCityID", DropDownStyle = DropDownStyle.DropDownList, DataSource = orderInfo.ShipCityDetails }); 
 
this.sfDataGrid1.Columns.Add(new GridComboBoxColumn() { MappingName = "ShippedID", HeaderText = "Shipped ID", DisplayMember = "ShipID", ValueMember = "ShipCityID", DropDownStyle = DropDownStyle.DropDownList, DataSource = orderInfo.ShipCityDetails }); 
 
 
Please refer the below sample link, 
 
    
Please let us know if you require further other assistance from us.          
    
Regards,    
Gowtham    
 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon