private void CarregaNoticia(int pTipoNoticiaId) { try { ddlNoticia.DataSource = DONoticia.Listar(new Noticia() { TipoNoticia = new TipoNoticia() { ID = pTipoNoticiaId } }); ddlNoticia.DataTextField = "Titulo"; ddlNoticia.DataValueField = "Id"; ddlNoticia.DataBind(); ddlNoticia.Items.Insert(0, new ListItem("Selecione a notícia", "-1")); ddlNoticia.SelectedIndex = 0; } catch (Exception ex) { throw ex; } }
private int BindNoticias() { int retorno = 0; try { List <Noticia> lst = new List <Noticia>(); lst = (List <Noticia>)Session["sNoticias"]; if (lst[0] != null && lst[0].ID > 0) { CarregaDestaque(lst[0].TipoArquivo.Id); lst = FiltrosNoticia(DONoticia.Listar(new Noticia() { TipoArquivo = new TipoArquivo() { Id = lst[0].TipoArquivo.Id } })); PagedDataSource pds = new PagedDataSource(); pds.DataSource = lst.OrderByDescending(x => x.DataNoticia).ToList(); pds.AllowPaging = true; pds.PageSize = 3; int count = pds.PageCount; pds.CurrentPageIndex = CurrentPage; if (pds.Count > 0) { lbtnPrev.Visible = true; lbtnNext.Visible = true; lbtnFirst.Visible = true; lbtnLast.Visible = true; lblStatus.Text = "| Página " + Convert.ToString(CurrentPage + 1) + " de " + Convert.ToString(pds.PageCount); } else { lbtnPrev.Visible = false; lbtnNext.Visible = false; lbtnFirst.Visible = false; lbtnLast.Visible = false; } lbtnPrev.Enabled = !pds.IsFirstPage; lbtnNext.Enabled = !pds.IsLastPage; lbtnFirst.Enabled = !pds.IsFirstPage; lbtnLast.Enabled = !pds.IsLastPage; rptNoticia.DataSource = pds; rptNoticia.DataBind(); retorno = count; } return(retorno); } catch (Exception ex) { throw ex; } }