private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{

if(e.Item.ItemType == ListItemType.EditItem)
{ CheckBoxList CBList= (CheckBoxList)e.Item.FindControl("CBLPopedom");
    String PopedomValue = DataBinder.Eval(e.Item.DataItem, "adminPopedom").ToString();

string [] Popedom=null;
if (PopedomValue!=null)
Popedom=PopedomValue.Split(null);

if (PopedomValue!=null)
{
for (int i=0;i<Popedom.Length;i++)
((CheckBoxList)e.Item.FindControl("CBLPopedom")).Items.FindByText(Popedom[i]).Selected=true;
}
DataGridBind();

}
}

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/3348/3348913.xml?temp=.9464685
    你看一下这里
      

  2.   

    string [] Popedom=null;
    初始化变量不能为null换个值试试
      

  3.   

    FindControl之后 如果没有咱好到该对象
    那么你得到的
    CBList有可能为null
    在下面用它就 “未将对象引用设置到对象的实例”了
    应该在FindControl后
    xxx zz= y.Findcontrol("zz");
    if(zz!=null)
    {
    //做你的事情
    }
      

  4.   

    FindControl之后 如果没有找到该对象
    那么比如你得到的
    CBList有可能为null
    在下面用它就 “未将对象引用设置到对象的实例”了
    应该在FindControl后
    xxx zz= y.Findcontrol("zz");
    if(zz!=null)
    {
    //做你的事情
    }