private void Load_SecondaryProductList() { try { if (gvFinishProduct.CurrentRow != null) { dtSecondaryProducts = objFinishProductDL.Get_SecondaryProductList_All(gvFinishProduct.CurrentRow.Cells["ColFinishProductCode"].Value.ToString()); dgvProductListSecondary.AutoGenerateColumns = false; bindSecondaryProduct.DataSource = dtSecondaryProducts; dgvProductListSecondary.DataSource = bindSecondaryProduct; bindSecondaryProduct.ResetBindings(true); txtPrimaryProductCode.Text = gvFinishProduct.CurrentRow.Cells["ColFinishProductCode"].Value.ToString(); } else { dtSecondaryProducts = null; dgvProductListSecondary.AutoGenerateColumns = false; bindSecondaryProduct.DataSource = dtSecondaryProducts; dgvProductListSecondary.DataSource = bindSecondaryProduct; bindSecondaryProduct.ResetBindings(true); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }