public ArrayList GetTbTypeList() { ArrayList list = new ArrayList(); string sql = "select * from tb_type"; DataTable dt = DBHelper.GetDataTable(sql); foreach (DataRow dr in dt.Rows) { TBType type = new TBType(); type.Id = Convert.ToInt32(dr["id"]); type.TypeIntro = dr["type_intro"].ToString(); list.Add(type); } return list; }
/// <summary> /// 获取并设置DropDownList的数据源 /// </summary> private void fillInfoType() { TBTypeService typeService = new TBTypeService(); ArrayList list = typeService.GetTbTypeList(); //Response.Write(list.Count); TBType temp = new TBType(); temp.Id = 0; temp.TypeIntro = "全部信息"; list.Insert(0, temp); ddlType.DataSource = list; ddlType.DataTextField = "TypeIntro"; ddlType.DataValueField = "Id"; ddlType.DataBind(); }