using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; namespace WebBlocks { public class DropDownListField : DataControlField { public DropDownListField() { } protected override DataControlField CreateField() { return new DropDownListField(); } public string DataTextField { get { return (string)ViewState["DataTextField"]; } set { ViewState["DataTextField"] = value; } } public string DataValueField { get { return (string)ViewState["DataValueField"]; } set { ViewState["DataValueField"] = value; } } public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex) { switch (cellType) { case DataControlCellType.Header: Literal li = new Literal(); li.Text = HeaderText; cell.Controls.Add(li); break; case DataControlCellType.DataCell: DropDownList ddl = new DropDownList(); ddl.DataTextField = DataTextField; ddl.DataValueField = DataValueField; if (ItemStyle.Width != null) ddl.Width = ItemStyle.Width; cell.Controls.Add(ddl); break; default: break; } } } }