The full text of the ListBoxesFTs_C.ascx.cs is the following (the comments to the code you can find in the first part):
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;
using System.Text;
using System.IO;
public partial class UserControls_ListBoxesFTs_C : System.Web.UI.UserControl,
System.Web.UI.ICallbackEventHandler
{
#region "forClass"
int _WidthLB = 60;
int _HeightLB = 120;
string _LabelFrom = ">>";
string _LabelTo = "<<";
DataTable _DT_In = null;
DataTable _DT_Out = null;
int _SortBy = 1;
string _Split = "|";
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
fillHidden(_DT_In, HiddenFromText, HiddenFromValue);
fillHidden(_DT_Out, HiddenToText, HiddenToValue);
}
else
{
getDT_Hidden();
}
buildListBox(ListBoxFrom, _DT_In);
buildListBox(ListBoxTo, _DT_Out);
ForCallBackOnLoad();
}
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);
ButtonHTMLFrom.Value = _LabelFrom;
ButtonHTMLTo.Value = _LabelTo;
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 + "," +
"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 + "," +
"false" + ")");
}
#region "Callback"
string _cb_Return = "";
public string GetCallbackResult()
{
StringBuilder SB = new StringBuilder();
bool bFrom;
int iSelected;
string sSplit = _Split;
Array arrReturn;
char[] cIndexOf = { '!' };
StringWriter sWriteTo = new System.IO.StringWriter();
HtmlTextWriter htmlWriterTo = new HtmlTextWriter(sWriteTo);
StringWriter sWriteFrom = new System.IO.StringWriter();
HtmlTextWriter htmlWriterFrom = new HtmlTextWriter(sWriteFrom);
arrReturn = _cb_Return.Split(cIndexOf);
iSelected = Convert.ToInt32(arrReturn.GetValue(0).ToString().Trim());
bFrom = Convert.ToBoolean(arrReturn.GetValue(1).ToString().Trim());
getDT_Hidden(arrReturn.GetValue(2).ToString().Trim(),
arrReturn.GetValue(3).ToString().Trim(),
arrReturn.GetValue(4).ToString().Trim(),
arrReturn.GetValue(5).ToString().Trim());
onClickFromTo(bFrom,iSelected );
ListBoxTo.RenderControl(htmlWriterTo);
ListBoxFrom.RenderControl(htmlWriterFrom);
SB.Append(FindControl(divListBoxTo.ID).ClientID);
SB.Append(sSplit);
SB.Append(sWriteTo.ToString());
SB.Append(sSplit);
SB.Append(FindControl(divListBoxFrom.ID).ClientID);
SB.Append(sSplit);
SB.Append(sWriteFrom.ToString());
SB.Append(sSplit);
SB.Append(this.Parent.ID + "." +
FindControl(ListBoxFrom.ID).ClientID);
SB.Append(sSplit);
SB.Append(this.Parent.ID + "." +
FindControl(ListBoxTo.ID).ClientID);
SB.Append(sSplit);
SB.Append(this.Parent.ID + "." +
FindControl(HiddenFromText.ID).ClientID);
SB.Append(sSplit);
SB.Append(this.Parent.ID + "." +
FindControl(HiddenFromValue.ID).ClientID);
SB.Append(sSplit);
SB.Append(this.Parent.ID + "." +
FindControl(HiddenToText.ID).ClientID);
SB.Append(sSplit);
SB.Append(this.Parent.ID + "." +
FindControl(HiddenToValue.ID).ClientID);
return SB.ToString();
}
public void RaiseCallbackEvent(string eventArgument)
{
_cb_Return = eventArgument;
}
private void ForCallBackOnLoad()
{
ClientScriptManager CS = Page.ClientScript;
String cbRef = CS.GetCallbackEventReference(this, "arg",
"ReceiveServerData", "");
String cbScript = "function CallTheServer(arg) {" +
cbRef + "; }";
CS.RegisterClientScriptBlock(this.GetType(), "CallTheServer",
cbScript, true);
}
private void onClickFromTo(bool clickFrom,int iSelected)
{
ListBox lb;
DataTable dtFrom;
DataTable dtTo;
int iItemsList = 0;
int iCount = 0;
int iCountHelp = 0;
if (clickFrom)
{
lb = ListBoxFrom;
dtFrom = _DT_In;
dtTo = _DT_Out;
}
else
{
lb = ListBoxTo;
dtFrom = _DT_Out;
dtTo = _DT_In;
}
iItemsList = dtFrom.Rows.Count;
for (iCount = 0; iCount < iItemsList; iCount++)
{
if (iCount == iSelected)
{
DataRow dr;
dr = dtTo.NewRow();
dr[0] = dtFrom.Rows[iCount - iCountHelp][0];
dr[1] = dtFrom.Rows[iCount - iCountHelp][1];
dtTo.Rows.Add(dr);
dtFrom.Rows[iCount - iCountHelp].Delete();
iCountHelp = iCountHelp + 1;
}
}
if (clickFrom)
{
_DT_In = dataTable_Sort(dtFrom.Copy());
_DT_Out = dataTable_Sort(dtTo.Copy());
}
else
{
_DT_Out = dataTable_Sort(dtFrom.Copy());
_DT_In = dataTable_Sort(dtTo.Copy());
}
buildListBox(ListBoxFrom, _DT_In);
buildListBox(ListBoxTo, _DT_Out);
}
#endregion
#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 DataTable C_DataIn
{
set
{
_DT_In = dataTable_Sort(value);
_DT_Out = _DT_In.Clone();
}
}
public DataTable C_DataOut

chen yongxiongPosted Apr 21, 2007, 10:24 PM
can you send this programmer to me my email:[email protected] thank you