//Servicio para obtener una lista de la participación del productor que estan participando en la solicitud de compra por IdPurchaseRequest y por IdProducer private void LoadDgvParticipating() { string token = Session.Token; dynamic parameters = new System.Dynamic.ExpandoObject(); parameters.idPurchaseRequest = Session.id; parameters.idProducer = Session.IdProfile; var findByIdPurchaseRequestAndIdProducer = VirtualFairIntegration.FindByIdPurchaseRequestAndIdProducer(token, parameters); List <string> lstNamesProducts = new List <string>(); List <AddProducts> lstSalesProcessesDetails = new List <AddProducts>(); List <AddProducts> lstAddProducts = new List <AddProducts>(); if (findByIdPurchaseRequestAndIdProducer.countRows != 0) { foreach (var item in findByIdPurchaseRequestAndIdProducer.purchaseRequestProducers) { AddProducts pRobject = new AddProducts(); pRobject.idPurchaseRequestProduct = item.idPurchaseRequestProduct; pRobject.nameProduct = item.purchaseRequestProduct.product.name; pRobject.weight = item.weight; pRobject.price = item.price.ToString(); lstSalesProcessesDetails.Add(pRobject); //lstNamesProducts.Add(item.product.name.ToString()); } } Session.lstNamesProducts = lstNamesProducts; lstAddProducts = Session.lstAddProducts; List <AddProducts> orderList = lstSalesProcessesDetails.OrderBy(x => x.idPurchaseRequestProduct).ToList(); dgvParticipating.AutoGenerateColumns = false; //var productsElements = from element in lstSalesProcessesDetails where dgvParticipating.DataSource = orderList; string[] arrayString = new string[] { "weight", "price" }; //List<PropertyInfo> lst = typeof(AdminApi).GetProperties().Where(x => x.Name == "id" || x.Name == "fullName" || // x.Name == "email" || x.Name == "nameProfile" ).ToList(); foreach (var item in arrayString) { DataGridViewTextBoxColumn dataGrid = new DataGridViewTextBoxColumn(); dataGrid.DataPropertyName = item; dataGrid.ReadOnly = true; if (item == "weight") { dataGrid.HeaderText = "Peso ofrecido Kg"; } if (item == "price") { dataGrid.HeaderText = "$ Valor por Kg"; } dataGrid.Name = item; dgvParticipating.Columns.Add(dataGrid); } }