现有一个gridview控件..内嵌套了一个别dropdownlist子控件..请教各位哥哥姐姐们,如何在编辑状态下即
protected void gvbind_RowEditing(object sender, GridViewEditEventArgs e)事件中找到dropdownlist子控件...

解决方案 »

  1.   

    (DropDownList)e.Row.Cells[9].FindControl("ddl")
      

  2.   

     DropDownList ddlXL = (DropDownList)e.Row.FindControl("ddlXL");
      

  3.   

    不好意思.. 我说错了..应该是在编辑事件
    protected void gvbind_RowEditing(object sender, GridViewEditEventArgs e)
    {
        //找到并绑定dropdownlist子控件...这里的代码应该怎么写...
    }
      

  4.   

    (DropDownList)gridview.Rows[e.NewEditIndex].FindControl("ddl")
      

  5.   

    GridViewRow drv = ((GridViewRow)(((LinkButton)(e.CommandSource)).Parent.Parent));
    DropDownList ddlXL=GridViewProject.Rows[drv.RowIndex].FindControl("ddl");
      

  6.   

    DropDownList ddl = (DropDownList)gridview.Rows[e.NewEditIndex].FindControl("ddl");
    ddl.DataSource = myTable;
    ddl.DataTextField = "ProductName";
    ddl.DataValueField = "ProductID";
    ddl.DataBind();
      

  7.   

    DropDownList ddl = (DropDownList)gridview.Rows[e.NewEditIndex].FindControl("ddl")
      

  8.   

    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {        DropDownList ddl = GridView1.Rows[e.RowIndex].Cells[3].FindControl("DropDownList1") as DropDownList;
        }
    是不是应该在这个事件里边写啊
      

  9.   

    参考:
    http://blog.csdn.net/insus/archive/2008/03/26/2221260.aspx
    http://www.cnblogs.com/insus/articles/1411016.html
      

  10.   

    应先判断是否为dataRow,再使用楼上各位的方法