在模版列中有一个dropdownlist在ItemDataBound事件中怎么帮定dropdownlist数据
为什么老是抱错"未将对象引用设置到实例",我已经转型了呀
((DropDownList)e.item.cell[0].controls[0]).DataSource=table;
((DropDownList)e.item.FindConrol("mydd")).DataSource=table;
都不行

解决方案 »

  1.   

    RowDataBound 事件里if (e.Row.RowType == DataControlRowType.DataRow)
            {           
                DropDownList ddl = (DropDownList)e.Row.FindControl("DropDownList1");
                对ddl操作
            }我是指在GridView等列表控件里
      

  2.   

    protected void Gvw_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                    DropDownList dl = (DropDownList)e.Row.FindControl("dlstSID");
                    BindDlst(dl);
            }
        }
    这是我的代码中这样写的。没有任何问题。
      

  3.   

    在 RowDataBound 事件里加