1 2 3 4 5 6 7 8 9 10 11 12 | <ComboBox HorizontalAlignment="Left" Margin="168,54,0,0" VerticalAlignment="Top" Width="197" x:Name="cmbProductCat"> <ComboBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding CategoryTitle}" Width="60"/> <!--<TextBlock Text="|"/> <TextBlock Text="{Binding DepartmentName}" Width="60"/>--> </StackPanel> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> |
Step - 2 (UI Code)
1 2 3 4 5 6 7 8 9 | private void LoadProductCatComboBox() { cmbProductCat.Items.Clear(); _productCategoryInfoList = _productCategoryInfoManager.LoadAllProductCategoryInfo(); foreach (ProductCategoryInfo pCatInf in _productCategoryInfoList) { cmbProductCat.ItemsSource = _productCategoryInfoList; } } |
Step - 3 (BLL)
1 2 3 4 | public List<ProductCategoryInfo> LoadAllProductCategoryInfo() { return productCatInfoGetway.LoadAllProductCategoryInfo(); } |
Step -4 (DAL)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | public List<ProductCategoryInfo> LoadAllProductCategoryInfo() { List<ProductCategoryInfo> productCategoryInfoList = new List<ProductCategoryInfo>(); foreach (var p in (from c in dataContext.tbl_ProductCategories select c).Distinct()) { ProductCategoryInfo productCatInfoObj = new ProductCategoryInfo(); productCatInfoObj.Id = p.ID; productCatInfoObj.CategoryTitle = p.CategoriesTitle; productCategoryInfoList.Add(productCatInfoObj); } return productCategoryInfoList; } |
No comments:
Post a Comment