撞墙吧 Array.IndexOf(xxx)
要在后台把CheckBoxList的某个ListItem 的selected给true了
遍历该CheckBoxList,写下了下面注释内的代码,死活不能选中我的第个CheckBox
半天不能醒悟就想着换道道,写了”该死”那行上面的几行代码把数组放倒来,(站着不行我就躺着来),发现可行,然后就开始发楞,命名原理一摸一样的啊,真是“见鬼”,对者这几行代码发了会愣,就决定还要狠狠的,
if (Array.IndexOf(xxxxx) > 0) 用力吧
555555,撞的头都疼了.
遍历该CheckBoxList,写下了下面注释内的代码,死活不能选中我的第个CheckBox
string bigClassId = ( ( DataRowView)e.Item.DataItem )["模块编号"].ToString();
string bigClassName = ( ( DataRowView)e.Item.DataItem )["模块名称"].ToString();
CheckBoxList chk_list_big = (CheckBoxList)e.Item.FindControl("chk_list_big") as CheckBoxList;
if(chk_list_big != null)
{
chk_list_big.Items.Clear();
ListItem item = new ListItem();
item.Text = bigClassName;
item.Value = bigClassId;
chk_list_big.Items.Add(item);
chk_list_big.Attributes["onclick"] = String.Format("CheckAll('{0}')",chk_list_big.ClientID);
//将符合用户模块的ListItem选定
for(int i=0; i<this.taxiUser.Modules.Length; i++)
{
if( bigClassId == this.taxiUser.Modules[i] )
{
chk_list_big.Items.FindByValue(this.taxiUser.Modules[i]).Selected = true;
}
}
//真是见了鬼了!为什么用这样的方法不能选定该ListItem???
// foreach(ListItem listItem in chk_list_big.Items)
// {
// if(Array.IndexOf(this.taxiUser.Modules,listItem.Value) > 0)
// {
// listItem.Selected = true;
// }
// }
string bigClassName = ( ( DataRowView)e.Item.DataItem )["模块名称"].ToString();
CheckBoxList chk_list_big = (CheckBoxList)e.Item.FindControl("chk_list_big") as CheckBoxList;
if(chk_list_big != null)
{
chk_list_big.Items.Clear();
ListItem item = new ListItem();
item.Text = bigClassName;
item.Value = bigClassId;
chk_list_big.Items.Add(item);
chk_list_big.Attributes["onclick"] = String.Format("CheckAll('{0}')",chk_list_big.ClientID);
//将符合用户模块的ListItem选定
for(int i=0; i<this.taxiUser.Modules.Length; i++)
{
if( bigClassId == this.taxiUser.Modules[i] )
{
chk_list_big.Items.FindByValue(this.taxiUser.Modules[i]).Selected = true;
}
}
//真是见了鬼了!为什么用这样的方法不能选定该ListItem???
// foreach(ListItem listItem in chk_list_big.Items)
// {
// if(Array.IndexOf(this.taxiUser.Modules,listItem.Value) > 0)
// {
// listItem.Selected = true;
// }
// }
半天不能醒悟就想着换道道,写了”该死”那行上面的几行代码把数组放倒来,(站着不行我就躺着来),发现可行,然后就开始发楞,命名原理一摸一样的啊,真是“见鬼”,对者这几行代码发了会愣,就决定还要狠狠的,
if (Array.IndexOf(xxxxx) > 0) 用力吧
555555,撞的头都疼了.