//Fill the dropdown with attribute public void FillDDLAttribute() { try { DataTable dtCategoryShowAll = categoryBLLObj.BLLGetCategoryWOParent(); ddlSelectCategory.DataSource = dtCategoryShowAll; ddlSelectCategory.DataTextField = "categoryName"; ddlSelectCategory.DataValueField = "categoryId"; ddlSelectCategory.DataBind(); ddlSelectCategory.Items.Add("---Select---"); ddlSelectCategory.SelectedIndex = ddlSelectCategory.Items.Count - 1; ddlSelectCategory.Items[ddlSelectCategory.Items.Count - 1].Value = ""; cmbCategory.DataSource = dtCategoryShowAll; cmbCategory.DataTextField = "categoryName"; cmbCategory.DataValueField = "categoryId"; cmbCategory.DataBind(); cmbCategory.Items.Add("---Select---"); cmbCategory.SelectedIndex = cmbCategory.Items.Count - 1; cmbCategory.Items[cmbCategory.Items.Count - 1].Value = ""; } catch (Exception ex) { throw ex; } }
private void BindCategory() { try { DataTable dtCategory = categoryBLLObj.BLLGetCategoryWOParent(); ddlSelectCategory.DataSource = dtCategory; ddlSelectCategory.DataTextField = "categoryName"; ddlSelectCategory.DataValueField = "categoryId"; ddlSelectCategory.DataBind(); ddlSelectCategory.Items.Add("---Select---"); ddlSelectCategory.SelectedIndex = ddlSelectCategory.Items.Count - 1; ddlSelectCategory.Items[ddlSelectCategory.Items.Count - 1].Value = ""; } catch (Exception ex) { throw ex; } }