DataGrid的模板的页脚里放了一个dropdownlist控件,作用是快速添加新行,在程序运行时在页脚绑定dropdownlist控件 
现在我在page_load事件里找不到dropdownlist控件的ID, 
dropdownlist控件梆定不了 

解决方案 »

  1.   

    private void Links_ItemCommand(object source, DataListCommandEventArgs e) {
    if(e.Item.ItemType==ListItemType.Footer) {
    ForumLink link = new ForumLink();
    link.Name = ((TextBox)e.Item.FindControl("NewLinkName")).Text.Trim();
    link.NavigateUrl = ((TextBox)e.Item.FindControl("NewLinkUrl")).Text.Trim();
    if(link.Name == String.Empty || link.NavigateUrl == String.Empty)return;
    ForumLinks.InsertForumLink(link);
    Links.EditItemIndex=((ArrayList)Links.DataSource).Count;
    Links.DataBind();
    }
    }这样就可以
      

  2.   

    ((DataList)DLjz.Items[i].FindControl("DLmore1")).DataSource = DBUtility.QueryByAdapter(sqlstr);前面的DataList是内藏的控件的类型,后面的DLmore1是控件的ID
      

  3.   

    DataGrid的ItemBound中
    if(e.Item.ItemType==ListItemType.Footer)
    {
    string sql = "... ";
    OleDbDataAdapter  objAdapter = new OleDbDataAdapter(sql,Conn);
    DataSet objDataSet = new DataSet();
    objAdapter.Fill(objDataSet,"product");
    DropDownList tempobj=(DropDownList)e.Item.FindControl("Dropdownlist");

    tempobj.DataSource=objDataSet.Tables["product"];
    tempobj.DataTextField=objDataSet.Tables["product"].Columns["name"].ToString();
    tempobj.DataValueField=objDataSet.Tables["product"].Columns["id"].ToString();
    tempobj.DataBind();
    }
      

  4.   

    你这个问题还问了两遍啊
    http://community.csdn.net/Expert/topic/3491/3491714.xml?temp=.7456324