More in this section

Forums / Developing with Sitefinity / Displaying news by custom field

Displaying news by custom field

1 posts, 0 answered
  1. David
    David avatar
    5 posts
    29 Jul 2014
    16 Sep 2014
    Link to this post

    Hi I am trying to create a dropdown in news widget using date, so that when I select the date from dropdown it displays news from that date forward. My approach was to add asp control for dropdown

    <asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="itemSelected" ></asp:DropDownList>

    In code behind I populated the dropdown

    protected void Page_Load(object sender, EventArgs e)
    int thisYear = Convert.ToInt32(System.DateTime.Now.Year);
    for(int i=2012; i<=thisYear; i++)
    DropDownList1.Items.Add(new ListItem(i.ToString(), i.ToString()));
    ListItem lsitem = new ListItem("Select Year Range", "0");
    DropDownList1.Items.Insert(0, lsitem);

    Than when item is selected from dropdown it calls following method in code behind

    protected void itemSelected(object sender, EventArgs e)

    I want to know if the approach is correct, if so than how to access the news by that year?


1 posts, 0 answered