Esempio n. 1
0
        private void PopulateSubCategories(int selectedID)
        {
            ProductSubcategory psc = new ProductSubcategory();
            int productCategoryID  = 0;

            try
            {
                productCategoryID = Int32.Parse(cmbCategories.SelectedValue.ToString());
            }
            catch
            {
                return;
            }
            if (productCategoryID < 1)
            {
                return;
            }
            string where = "[ProductCategoryID]=" + productCategoryID;
            string orderBy = "[Name]";

            try
            {
                SubCategoryDs = psc.GetProductSubcategoryDataSet(where, orderBy);
                subcategoryGrid.DataSource = SubCategoryDs.Tables[0];
                subcategoryGrid.Columns.Remove("ModifiedDate");
                subcategoryGrid.Columns["ProductCategoryID"].Visible    = false;
                subcategoryGrid.Columns["ProductSubcategoryID"].Visible = false;
                if (selectedID > 0)
                {
                    for (int i = 0; i < subcategoryGrid.Rows.Count; i++)
                    {
                        int id = Int32.Parse(SubCategoryDs.Tables[0].Rows[i]["productsubcategoryid"].ToString());
                        if (id == selectedID)
                        {
                            subcategoryGrid.Rows[i].Selected = true;
                            subcategoryGrid.FirstDisplayedScrollingRowIndex = i;
                            GridRowChanged(i);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Product Subcategories", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                psc = null;
                //ds = null;
            }
        }