例如你有一个Button事件:
private void Button1_Click(object sender, System.EventArgs e)
{
for(int i=0;i<Management.Items.Count;i++)
{
if(Management.Items[i].Selected==true)
{
//do something
return;
}
}
Label1.Text="至少要选择其中一项"; }
RadioButtonList一样适用.

解决方案 »

  1.   

    check the value of Management when the page do postback.
    if the value is null, procsss the error handler.
      

  2.   

    在checklistbox的ItemCheck里做个判断:(我刚好用过)
    private void chklstTable_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
    {
    if(this.chklstTable.CheckedIndices.Count<2&&e.NewValue==System.Windows.Forms.CheckState.Unchecked)
    {
    e.NewValue = System.Windows.Forms.CheckState.Checked;
    }
    }
      

  3.   

    哎哟,抱歉,我用的是WinForm,不知道Asp.net 里可不可以給ItemChecked加事件(惭愧阿,不熟悉),不过可用的办法是在太多了