English 中文(简体)
制作两个相互排斥的检查箱清单
原标题:Make two checkbox lists mutually exclusive

亲善的朋友们,

I got to know how we can make two checkboxes or checkboxes inside a checkbox list mutually exclusive. However my question is little different from that, Hope to get some help from stack overflow,

我有两个核对箱清单,如下和数据集表所示,我正在获得检查箱值,

检查局Boxlist1 - 检查箱

 if (IsDataSetNotEmpty(ds))
 {
   CheckBox_selectColumns.Items.Clear();
   foreach (DataRow row in ds.Tables[0].Rows)
   {
     CheckBox_selectColumns.Items.Add(row[0].ToString());
   }

 }

核对表

if (IsDataSetNotEmpty(ds))
{
  Checkbox_selectFields.Items.Clear();
  foreach (DataRow row in ds.Tables[1].Rows)
  {
    CheckBox_selectColumns.Items.Add(row[0].ToString());
  }

}

I will get following checkboxes in each lists.

检查箱:Employee ID, 第一名称,最后名称

Checkbox_selectFields : manager ID, Manager FName, Manager LName

如果有的话,我可以把这两个检查箱相互排斥,即如果我从第一个清单中选择一个或一个以上的检查箱,我就不应从第二个清单中选择任何检查箱,反之亦然。

Thank you...

最佳回答
问题回答

此前,在Tim stips的帮助下,就这一问题开展了工作。 如果你容易找到解决办法,请提供解决办法。

protected void CheckBox_selectColumns_SelectedIndexChanged(object sender, EventArgs e)
        {
            bool Is_select = false;
            foreach (ListItem listItem in CheckBox_selectColumns.Items) 
            {
                if (listItem.Selected)
                {
                    Is_select = true;
                }

            }

            if (Is_select)
            {
                foreach (ListItem listItem in CheckBox_SelectAll.Items) 
                {
                   if (listItem.Selected)
                   {
                      listItem.slected=false;
                   }

                }
            }

        }

第二份检查箱清单正好相反。

        protected void CheckBox_SelectAll_CheckedChanged(object sender, EventArgs e)
        {
           bool Is_select = false;
            foreach (ListItem listItem in CheckBox_SelectAll.Items) 
            {
                if (listItem.Selected)
                {
                    Is_select = true;
                }

            }

            if (Is_select)
            {
                foreach (ListItem listItem in CheckBox_selectColumns.Items) 
                {
                   if (listItem.Selected)
                   {
                      listItem.slected=false;
                   }

                }
            }
        }

这样做是正确的,使《守则》更加完善的任何建议都将真正有用。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签