Hello Team,
Please in my window form application, am trying to load Category on the product entry form and save and my issues is category is not loading.
CLASS
public static void CBFill(string qry, ComboBox cb) { SqlCommand cmd = new SqlCommand(qry, con); cmd.CommandType = CommandType.Text; SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); cb.DataSource = dt; cb.SelectedIndex = -1; }
PRODUCT ENTRY FORM PAGE
private void frmProductAdd_Load(object sender, EventArgs e) { string qry = @"Select CategoryId 'id', CategoryName 'name' from tblCategory"; MainClass.CBFill(qry, cmbCategory); if (id > 0) { cmbCategory.SelectedValue = catID; LoadImage(); } }