protected void Page_Load(object sender, EventArgs e) { var catBL = new CatBL(false); var catsList = catBL.GetAllCats(); var dt = new DataTable(); var dcBreed = new DataColumn("Breed", typeof(string)); var dcCountry = new DataColumn("Country", typeof(string)); var dcOrigin = new DataColumn("Origin", typeof(string)); var dcBodyType = new DataColumn("Body Type", typeof(string)); var dcCoat = new DataColumn("Coat", typeof(string)); var dcPattern = new DataColumn("Pattern", typeof(string)); var dcImage = new DataColumn("Image", typeof(string)); dt.Columns.AddRange(new[] { dcBreed, dcCountry, dcOrigin, dcBodyType, dcCoat, dcPattern, dcImage }); for (var i = 0; i < catsList.Count; i++) { dt.Rows.Add(new object[] { catsList.ElementAt(i).GetBreed().Trim(), catsList.ElementAt(i).GetCountry().Trim(), catsList.ElementAt(i).GetOrigin().Trim(), catsList.ElementAt(i).GetBodyType().Trim(), catsList.ElementAt(i).GetCoat().Trim(), catsList.ElementAt(i).GetPattern().Trim(), ResolveUrl(catsList.ElementAt(i).GetImage().Trim()) }); } AllBreedGrid.DataSource = dt; AllBreedGrid.DataBind(); }
protected void Page_Init(object sender, EventArgs e) { _catBL = new CatBL(!_admin); _userCatBL = new CatBL(false); var catsList = _userCatBL.GetAllCats(); ChooseBreedDownList.Items.Add("Choose Breed"); foreach (var cat in catsList) { ChooseBreedDownList.Items.Add(cat.GetBreed()); } }