DropDownList dp=(DropDownList)e.Item.FindControl("dp");
dp.DataSource=ds;
dp.DataTextField="aaa";
dp.DataValueField="bbb";
dp.DataBind();

解决方案 »

  1.   

    DropDownList dp=(DropDownList)e.Item.FindControl("dp");这句话根本就没得到DropDownList ,不知道这种情况都有什么原因啊??
      

  2.   

    怎样得到Header、Footer、Pager里的控件
    方法一:在ItemCreated或者ItemDataBound中,具体代码就不在多写了
    方法二:遍历DataGrid的所有Item(注意,不是遍历DataGrid1.Items下的Item)
    foreach (DataGridItem item in DataGrid1.Controls[0].Controls)
    {
      if (item.ItemType == ListItemType.Header)
      {
        //用item.FindControl查找相应的控件
      }
    }
    大家可能会注意到,这里有个DataGrid1.Controls[0].Controls,这表示,DataGrid1下,有一个子控件,这个子控件是DataGridTable类型,他下面才是DataGridItem集合
    在DataList中,下面的子控件直接就是DataListItem了,而没有Table:
    foreach (DataListItem item in DataList1.Controls)
    {
      //....
    }
      

  3.   

    >>DropDownList dp=(DropDownList)e.Item.FindControl("dp");.FindControl("dp")中的 dp 是什么意思?
      

  4.   

    为什么DataList 显示数据,如果不加条件显示出来的数据是那么多相同的数据呢??为什么不是不同得数据呢,还是那块属性没有设置正确啊?还是DataList只能显示一行啊??
    这个问题一直困扰我??弄不明白!!!
      

  5.   

    goody9807仁兄说的不错MSDN中有关于DATAGRID的模板列绑定实现的例子的,查查吧