title: Loading Comboboxes and Setting its value in each row in Datagridview
body: <p>I am displaying the data in datagridview when user enters PickingNoteNo in the textbox.Then i am adding two comboxes to the Datagridview programatically and setting their respective Datasource.But the data is not displayed in the Comboboxes.can you please tell me changes in my code.</p>
  
  <pre><code>private void LoadDeliveryNoteDetails(string PickingNoteNo)
          {          
  
              dtDeliveryNoteDetails = new DataTable();
              try
              {
                  using (QuotationBusiness objQuotationBusiness = new QuotationBusiness())
                  {
                      dtDeliveryNoteDetails = objQuotationBusiness.GetDeliveryNoteDetails(PickingNoteNo);
  
                  }
                  if (dtDeliveryNoteDetails != null)
                  {
                      gvDeliveryNoteDetails.DataSource = dtDeliveryNoteDetails;
                      HideGridViewColumns();
                      LoadCustomerDetails();
                      LoadDeliveryDetails();
                      LoadFreightDetails();
                      LoadPackagingTypeDetails();
                      LoadShippingBoxDetails();
  
  
  
  
                  }
  
              }
              catch (Exception ex)
              {
  
              }
          }
          private void HideGridViewColumns()
          {
              foreach (DataGridViewColumn column in gvDeliveryNoteDetails.Columns)
              {
                  if (column.Name != "ItemCode" &amp;&amp; column.Name != "Quantity" &amp;&amp; column.Name != "Description" &amp;&amp; column.Name != "BatchNo"
                      &amp;&amp; column.Name != "ExpiryDate" &amp;&amp; column.Name != "Packaging Type")
                  {
  
                      column.Visible = false;
  
                  }
              }
  
  
          }
  
  
          private void LoadPackagingTypeDetails()
          {
              DataGridViewComboBoxColumn cmbpackingtype = new DataGridViewComboBoxColumn();
              cmbpackingtype.Name = "cmbPackingTypes";
              cmbpackingtype.HeaderText = "Packaging Type";
              gvDeliveryNoteDetails.Columns.Add(cmbpackingtype);
  
              using (QuotationBusiness objQB = new QuotationBusiness())
              {
                  DataTable dtPackingTypes = objQB.GetPackagingTypeDetails();
                  if (dtPackingTypes != null)
                  {
                      DataRow row = dtPackingTypes.NewRow();
                      row["PackageType"] = "Select";
                      row["PackageTypeID"] = 0;
                      dtPackingTypes.Rows.InsertAt(row, 0);
                      cmbpackingtype.ValueMember = "PackageTypeID";
                      cmbpackingtype.DisplayMember = "PackageType";
                      cmbpackingtype.DataSource = dtPackingTypes;
                      cmbpackingtype.DisplayIndex = 0;
  
  
                  }
              }
  
          }
          private void LoadShippingBoxDetails()
          {
              DataGridViewComboBoxColumn cmbBox = new DataGridViewComboBoxColumn();
              cmbBox.Name = "cmbBoxNos";
              cmbBox.HeaderText = "Box No";
              gvDeliveryNoteDetails.Columns.Add(cmbBox);
              using (EmployeeMasterBusiness objEmp = new EmployeeMasterBusiness())
              {
                  DataTable dtBoxNos = objEmp.GetDepartmentDetails();
                  if (dtBoxNos != null)
                  {
                      DataRow row = dtBoxNos.NewRow();
                      row["DeptName"] = "Select";
                      row["DeptID"] = 0;
                      dtBoxNos.Rows.InsertAt(row, 0);
                      cmbBox.DataSource = dtBoxNos;
                      cmbBox.DisplayMember = "DeptName";
                      cmbBox.ValueMember = "DeptID";
  
                  }
              }
  
          }
  </code></pre>
  
  <p>After setting the datasource in every Row there is PackingID and ShippingID and we need to set the Comboxes Selected value to PackingID for cmbpackingtype ComboBox and ShippingID  for cmbBox.Later we can select a new value from the comboboxes and save the data to Database.</p>
  
  <p>1) How do I populate data in Comboboxes.
  2) How do i get the selected value from the combobox.</p>
  
  <p>Also there is one more requirement.If the value is selected in the Combobox i.e cmbpackingtype (data like Cartons,Pallets,Boxes) then I need to load the Combox cmbBox depending on PackingID.</p>
  
  <p>Thanks.</p>