лл´ó¼Ò£¬ÎÞÒԻر¨£¬Ìùµã¶ù¶«Î÷°É¡£
¸Õ²Å¿´µ½Ï±߲»ÉÙÈËÎʸødatatable»òtableÌí¼ÓÒ»¸öÑ¡Ôñ¿ò£¬Êµ¼ÊÉÏÈç¹ûÄã¿ÉÒÔ×Ô¼º×öÒ»¸öwebcontrolÀ´ÊµÏÖÕâ¸ö¹¦ÄÜ£¬Ï±ßÊÇÎÒ×öµÄÒ»¸ö´øcheckboxµÄwebcontrol£¬ÓÉÓÚ×¢ÊͱȽÏÈ«£¬ËùÒÔÎҾͲ»¼Ó˵Ã÷ÁË¡£
using System;
using System.Collections ;
using System.Web.UI.WebControls ;
using System.Web.UI ;
namespace Bigeagle.Web.WebControls
{
///
///
×Ô¶¨Òå¿Ø¼þ£¬´øÑ¡Ôñ¿òµÄTable
///
Author: Bigeagle@163.net
///
Date: 2001/10/10
///
History: 2001/10/10 finished
///
///
/// ¼Ì³ÐSystem.Web.UI.WebControls.Table£¬Ôö¼ÓCheckedValueÊôÐÔ£¬
/// ÓÃÓÚ¶àÏîÑ¡ÔñµÄ³¡ºÏ£¬·µ»Ø±»Ñ¡ÔñµÄCheckTableRowµÄÖµµÄÊý×é
///
public class CheckTable : System.Web.UI.WebControls.Table
{
///
/// ÊÇ·ñʹÓÃcheckbox
///
///
private bool m_bUseCheck ;
///
/// µÑ¡ÔñÊý×é
///
///
private ArrayList m_arrCheckedValue ;
///
/// È¡µÃÑ¡ÔñÊý×éµÄÊôÐÔ
///
///
public ArrayList CheckedValue
{
get
{
return this.m_arrCheckedValue ;
}
}
///
/// ´æÈ¡ÊÇ·ñʹÓÃcheckboxµÄÊôÐÔ
///
public bool UseCheck
{
get
{
return this.m_bUseCheck ;
}
set
{
this.m_bUseCheck = value ;
}
}
///
/// ¹¹Ô캯Êý
///
public CheckTable()
{
this.m_arrCheckedValue = new ArrayList() ;
this.m_bUseCheck = true ;
}
///
/// ÖØÔØ¸¸Àà·½·¨
///
///
protected override void OnLoad(System.EventArgs e)
{
if(this.m_bUseCheck)
{
try
{
for(int i = 0 ; i < this.Rows.Count ; i++)
{
CheckTableRow ctr = (CheckTableRow)this.Rows[i] ;
CheckBox cb = (CheckBox)ctr.FindControl(ctr.Value) ;
if(cb.Checked)
{
this.m_arrCheckedValue.Add(ctr.Value) ;
}
}
}
catch(Exception) //Ò»°ã³öÏÖÒì³£ÊÇÒòΪÓÐÖØ¸´µÄ¿Ø¼þid
{
throw(new Exception("³öÏÖÖØ¸´µÄ¿Ø¼þid")) ;
}
}
}//end method
}//end class
}//end method
using System;
using System.Web.UI.WebControls ;
using System.Web.UI ;
namespace Bigeagle.Web.WebControls
{
///
///
×Ô¶¨Òå¿Ø¼þ£¬´øÑ¡Ôñ¿òµÄTableRow
///
Author: Bigeagle@163.net
///
Date: 2001/10/10
///
History: 2001/10/10 finished
///
///
/// ¼Ì³ÐSystem.Web.UI.WebControls.TableRow , ×÷Ϊ×Ô¶¨Òå¿Ø¼þCheckTableµÄTableRow£¬
/// ÓëTableRowÏà±È£¬Ôö¼ÓÒ»¸öÖµÊôÐÔºÍÒ»¸öCheckBox
///
public class CheckTableRow : System.Web.UI.WebControls.TableRow
{
///
/// Öµ
///
private string m_strValue ;
///
/// ÊÇ·ñʹÓÃcheckbox
///
///
private bool m_bUseCheck ;
///
/// ´æÈ¡valueµÄÊôÐÔ
///
public string Value
{
get
{
return this.m_strValue ;
}
set
{
this.m_strValue = value ;
}
}
///
/// ´æÈ¡ÊÇ·ñʹÓÃcheckboxµÄÊôÐÔ
///
public bool UseCheck
{
get
{
return this.m_bUseCheck ;
}
set
{
this.m_bUseCheck = value ;
}
}
///
/// ¹¹Ô캯Êý
///
public CheckTableRow()
{
this.m_strValue = "" ;
this.m_bUseCheck = true ;
}
///
/// ÖØÔØ¸¸Àà·½·¨
///
///
///
protected override System.Web.UI.ControlCollection CreateControlCollection()
{
ControlCollection cc = base.CreateControlCollection() ;
if(this.m_bUseCheck)
{
TableCell td = new TableCell() ;
td.BackColor = this.BackColor ;
td.VerticalAlign = VerticalAlign.Top ;
CheckBox cb = new CheckBox() ;
cb.ID = this.m_strValue ;
td.Controls.Add(cb) ;
cc.Add(td) ;
}
return cc ;
}//end method
}//end class
}//end namespace

