private void frmCategory_Load(object sender, EventArgs e) { CategoryBusiness pb = new CategoryBusiness(); List <CategoryTbl> categories = pb.GetAllCategory(); DataTable categoryData; if (categories != null && categories.Count > 0) { categoryData = Common.ListToDataTable(categories); if (categoryData != null) { dgvCategory.DataSource = categoryData; } else { MessageBox.Show("Some Error Occured in Convert List<T> to DataTable!"); } } else { MessageBox.Show("Categories table is empty!"); } }