프로그래밍/ASP.NET

Dropdownlist - DB에 있는 데이터와 임의의 행 바운딩

Doonee 2013. 10. 16. 15:48
반응형

private void initDropList()
{
      DBDataControl EnvilCategory = new DBDataControl();

      DataSet categoryList EnvilCategory.GetCateGoryList(WebConfig.ConStr, "1");
      categoryDropList = categoryList.Tables[0].DefaultView;

      drpListCategory.DataSource = categoryDropList;
      drpListCategory.DataTextField = "CATEGORY_NAME";
      drpListCategory.DataValueField = "CATEGORY_SEQ";
      drpListCategory.SelectedIndex = GetCategoryIndex(this.categoryOffset);
      drpListCategory.DataBind();

 

      // 행 추가하기 (Select a Category)
      ListItem selectItem = new ListItem();
      selectItem.Text = "Select a Category";
      selectItem.Value = "0";
      drpListCategory.Items.Insert(0, selectItem);
      drpListCategory.SelectedIndex = 0;

}