Hi,
Please let me know where I am going wrong in loading data in the DatagridviewComboboxColumn.
Below is the code.
//Loading the DataGridview and adding the ComboBoxColumn using below method.
private void LoadDataGridview()
{
try
{
using (QuotationBusiness objQuotationBusiness = new QuotationBusiness())
{
dtDeliveryNoteDetails = objQuotationBusiness.GetDeliveryNoteDetails(PickingNoteNo);
}
if (dtDeliveryNoteDetails != null)
{
gvDeliveryNoteDetails.DataSource = dtDeliveryNoteDetails;
DataGridViewComboBoxColumn cmbpackingtype = new DataGridViewComboBoxColumn();
cmbpackingtype.Name = "cmbPackingTypes";
cmbpackingtype.HeaderText = "Packing Type";
cmbpackingtype.ReadOnly = false;
gvDeliveryNoteDetails.Columns.Add(cmbpackingtype);
///Loading Data into ComboBox
LoadPackagingTypeDetails(cmbpackingtype);
}
}
catch (Exception ex)
{
}
private void LoadPackagingTypeDetails(DataGridViewComboBoxColumn 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.DataSource = dtPackingTypes; //using a datatable as Datasource to Combobox
cmbpackingtype.ValueMember = "PackageTypeID";
cmbpackingtype.DisplayMember = "PackageType";
cmbpackingtype.DefaultCellStyle.NullValue = "--Select--";
}
}
}
But the ComboBox is not loading with the Data.When I click on the Combobox even the dropdown is not displayed.Just the --Select-- is displayed.How do we change the style to DropDownList and load the data