or

<li class="rtLI"><div class="rtMid">
<span class="rtSp"></span><input type="checkbox" class="rtChk" /><img src="images/page_white_text.png" alt="" class="rtImg" /><a class="rtIn rednode" href="javascript:setValue('10003')">Great Deals</a>
</div></li>
| namespace Company.PDC.WebParts |
| { |
| using System; |
| using System.Collections; |
| using System.ComponentModel; |
| using System.Web.UI; |
| using System.Web.UI.WebControls; |
| using Telerik.Web.UI; |
| [ToolboxData("<{0}:SearchListBox runat=server></{0}:SearchListBox>")] |
| public class SearchListBox : WebControl |
| { |
| #region Attributes |
| private Table listBoxTable; |
| private RadListBox source; |
| private RadListBox target; |
| private string separator = ";"; |
| private string anyElement = "- Any -"; |
| private int height = 200; |
| private int width = 200; |
| #endregion |
| #region Constructors |
| public SearchListBox(string controlName, IEnumerable dataSource, string textField, string valueField) |
| { |
| this.ID = controlName; |
| this.source = new RadListBox(); |
| this.target = new RadListBox(); |
| this.EnableViewState = true; |
| this.source.EnableViewState = true; |
| this.target.EnableViewState = true; |
| this.LoadData(dataSource, textField, valueField); |
| } |
| #endregion |
| #region Properties |
| public string Separator |
| { |
| get |
| { |
| return this.separator; |
| } |
| set |
| { |
| this.separator = value; |
| } |
| } |
| public string AnyElement |
| { |
| get |
| { |
| return this.anyElement; |
| } |
| set |
| { |
| this.anyElement = value; |
| } |
| } |
| public new int Height |
| { |
| get |
| { |
| return this.height; |
| } |
| set |
| { |
| this.height = value; |
| } |
| } |
| public new int Width |
| { |
| get |
| { |
| return this.width; |
| } |
| set |
| { |
| this.width = value; |
| } |
| } |
| public bool IsEmpty |
| { |
| get |
| { |
| return this.target.Items.Count.Equals(0); |
| } |
| } |
| #endregion |
| #region Public Methods |
| /// <summary> |
| /// Retrieves a list of selected items. |
| /// </summary> |
| /// <returns> |
| /// A separator delimited string of selected values. |
| /// </returns> |
| public string GetSelectedValues() |
| { |
| string values = string.Empty; |
| foreach (RadListBoxItem item in this.target.Items) |
| { |
| values += item.Value + this.Separator; |
| } |
| return values; |
| } |
| #endregion |
| #region Override Methods |
| protected override void CreateChildControls() |
| { |
| base.CreateChildControls(); |
| this.DefineListBoxes(); |
| this.Controls.Add(this.listBoxTable); |
| } |
| protected override void RenderContents(HtmlTextWriter output) |
| { |
| this.source.RenderControl(output); |
| this.target.RenderControl(output); |
| } |
| #endregion |
| #region Private Support Methods |
| private void LoadData(IEnumerable dataSource, string textField, string valueField) |
| { |
| this.source.DataSource = dataSource; |
| this.source.DataTextField = textField; |
| this.source.DataValueField = valueField; |
| this.source.DataBind(); |
| } |
| private void DefineListBoxes() |
| { |
| this.source.Height = this.Height; |
| this.source.Width = this.Width; |
| this.target.Height = this.Height; |
| this.target.Width = this.Width - 35; |
| this.target.ID = this.ID + "target"; |
| this.source.ID = this.ID + "source"; |
| this.source.AllowTransfer = true; |
| this.source.AllowTransferDuplicates = false; |
| this.source.TransferMode = ListBoxTransferMode.Copy; |
| this.source.TransferToID = this.target.ID; |
| this.listBoxTable = new Table(); |
| TableRow row = new TableRow(); |
| TableCell cellSource = new TableCell(); |
| TableCell cellTarget = new TableCell(); |
| cellSource.Controls.Add(this.source); |
| cellTarget.Controls.Add(this.target); |
| row.Cells.Add(cellSource); |
| row.Cells.Add(cellTarget); |
| this.listBoxTable.Rows.Add(row); |
| } |
| #endregion |
| } |
| } |