using System; using System.Collections.Generic; using System.ComponentModel; using System.Web.UI.WebControls; using SiberTek.Xenta.Presentation.Presenters; using SiberTek.Xenta.Presentation.Views; using SiberTek.Xenta.Web.Controls; namespace SiberTek.Xenta.Web.Forum.Modules { public partial class ForumDropDownList : ViewBase<ForumPresenter>, IDropDownList<Int32?> { #region Events public event EventHandler SelectedIndexChanged; #endregion #region Properties public int? ParentForumID { get { return null; } } public bool AutoPostBack { get { return lstForumList.AutoPostBack; } set { lstForumList.AutoPostBack = value; } } public bool AllowEmptyItem { get { return Convert.ToBoolean(ViewState["AllowEmptyItem"]); } set { ViewState["AllowEmptyItem"] = value; } } [Browsable(false)] public int? SelectedValue { get { return String.IsNullOrEmpty(lstForumList.SelectedValue) ? (int?)null : Int32.Parse(lstForumList.SelectedValue); } set { lstForumList.SelectedValue = value.HasValue ? value.Value.ToString() : String.Empty; } } public int ItemCount { get { return lstForumList.Items.Count; } } public bool Enabled { set { lstForumList.Enabled = value; } } #endregion #region Methods public override void BindData() { DataContainer["ShowHidden"] = false; DataContainer["ParentForumID"] = ParentForumID; Presenter.LoadCollection(); lstForumList.Items.Clear(); List<ViewDataContainer> itemCollection = DataContainer["ForumCollection"] as List<ViewDataContainer>; if(AllowEmptyItem) { lstForumList.Items.Add(new ListItem("-", String.Empty)); } foreach(ViewDataContainer item in itemCollection) { lstForumList.Items.Add(new ListItem((string)item["Title"], item["ForumID"].ToString())); } base.BindData(); } #endregion #region Handlers protected void LstForumList_OnSelectedIndexChanged(object sender, EventArgs e) { FireSelectedIndexChangedEvent(); } #endregion #region Utilities private void FireSelectedIndexChangedEvent() { if(SelectedIndexChanged != null) { SelectedIndexChanged(this, EventArgs.Empty); } } #endregion } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The MIT License