private void SetarViewBag(int id = -1) { var productList = new SelectList(this.productService.GetAll(), "ID", "Name"); var enumerator = productList.GetEnumerator(); if (id > -1) { while (enumerator.MoveNext()) { if (int.Parse(enumerator.Current.Value) == id) { enumerator.Current.Selected = true; break; } } } ViewBag.ProductList = productList; }