日期:2014-05-17 浏览次数:20473 次
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//先遍历CheckBoxList 取出只有1个选项时辰的index
int iCount=0;int iTemp=0;
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected)
{
iCount++;
iTemp=i;
}
}
if (iCount == 1)
{
ViewState["oldSelect"] = iTemp;
}
}
protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (!CheckBox1.Checked)
{
int iCount = 0;
int iTemp = (Int32)ViewState["oldSelect"];
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
&nb