The full text of the ListBoxesFT_C.ascx.cs is the following (the comments to the code you can find in the part 1, part 2 and part 3):
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;
public partial class UserControls_ListBoxesFT_C : System.Web.UI.UserControl
{
#region "forClass"
int _WidthLB = 60;
int _HeightLB = 120;
string _LabelFrom = ">>";
string _LabelTo = "<<";
DataTable _DT_In = null;
DataTable _DT_Out = null ;
bool _Client = false;
bool _SortByText = true;
int _SortBy = 1;
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
buildListBox(ListBoxFrom, _DT_In);
buildListBox(ListBoxTo, _DT_Out);
if (_Client)
{
fillHidden(_DT_In, HiddenFromText, HiddenFromValue);
fillHidden(_DT_Out, HiddenToText, HiddenToValue);
}
}
else
{
if (_Client)
{
getDT_Hidden();
buildListBox(ListBoxFrom, _DT_In);
buildListBox(ListBoxTo, _DT_Out);
}
}
}
protected void Page_PreRender(object sender, EventArgs e)
{
if (IsPostBack)
{ return; }
ListBoxFrom.Width = Unit.Pixel(_WidthLB);
ListBoxFrom.Height = Unit.Pixel(_HeightLB);
ListBoxTo.Width = Unit.Pixel(_WidthLB);
ListBoxTo.Height = Unit.Pixel(_HeightLB);
ButtonFrom.Text = _LabelFrom;
ButtonTo.Text = _LabelTo ;
ButtonHTMLFrom.Value = _LabelFrom;
ButtonHTMLTo.Value = _LabelTo;
ButtonFrom.Visible = false;
ButtonTo.Visible = false;
ButtonHTMLFrom.Visible = false;
ButtonHTMLTo.Visible = false;
if (_Client)
{
ButtonHTMLFrom.Visible = true;
ButtonHTMLTo.Visible = true;
ButtonHTMLFrom.Attributes.Add("onClick",
"javascript:ButtonHTML_onclick(" +
this.Parent.ID + "." + FindControl(ListBoxFrom.ID).ClientID + "," +
this.Parent.ID + "." + FindControl(ListBoxTo.ID).ClientID + "," +
this.Parent.ID + "." + FindControl(HiddenToText.ID).ClientID + "," +
this.Parent.ID + "." + FindControl(HiddenToValue.ID).ClientID + "," +
this.Parent.ID + "." + FindControl(HiddenFromText.ID).ClientID + "," +
this.Parent.ID + "." + FindControl(HiddenFromValue.ID).ClientID + "," +
_SortByText.ToString().ToLower() + "," + "true" + ")");
ButtonHTMLTo.Attributes.Add("onClick",
"javascript:ButtonHTML_onclick(" +
this.Parent.ID + "." + FindControl(ListBoxFrom.ID).ClientID + "," +
this.Parent.ID + "." + FindControl(ListBoxTo.ID).ClientID + "," +
this.Parent.ID + "." + FindControl(HiddenToText.ID).ClientID + "," +
this.Parent.ID + "." + FindControl(HiddenToValue.ID).ClientID + "," +
this.Parent.ID + "." + FindControl(HiddenFromText.ID).ClientID + "," +
this.Parent.ID + "." + FindControl(HiddenFromValue.ID).ClientID + "," +
_SortByText.ToString().ToLower() + "," + "false" + ")");
}
else
{
ButtonFrom.Visible = true;
ButtonTo.Visible = true;
}
}
#region "properties"
public int C_SortBy
{
get { return _SortBy; }
set { _SortBy = value; }
}
public int C_WidthLB
{
get { return _WidthLB; }
set { _WidthLB = value; }
}
public int C_HeightLB
{
get { return _HeightLB; }
set { _HeightLB = value; }
}
public string C_LabelFrom
{
get { return _LabelFrom; }
set { _LabelFrom = value; }
}
public string C_LabelTo
{
get { return _LabelTo; }
set { _LabelTo = value; }
}
public bool C_Client
{
get { return _Client; }
set { _Client = value; }
}
public bool C_SortByText
{
get { return _SortByText; }
set { _SortByText = value; }
}
public DataTable C_DataIn
{
set
{
_DT_In = dataTable_Sort ( value);
//Clones the structure of the _DT_In DataTable
_DT_Out = _DT_In.Clone();
//here you can set default value for the _DT_Out
}
}
public DataTable C_DataOut
{
get{return _DT_Out;}
}
#endregion
//-----------------------------------------------------------------
private DataTable dataTable_Sort(DataTable dt)
{
DataView dv;
DataTable dtHelp;
DataRow dr;
int iCount = 0;
int iMax = dt.Rows.Count;
dtHelp = dt.Copy();
dv = dtHelp.DefaultView;
dv.Sort = dt.Columns[_SortBy].Caption ;
dt.Clear();
for (iCount = 0; iCount < iMax; iCount++)
Join the conversation! Your thoughts help the community grow.