比如我textbox可以用 text=<%#Eval("xx")%>那gridview里面的dropdownlist怎么进行绑定啊??

解决方案 »

  1.   

    你可以
     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
      {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
          DropDownList d = e.Row.FindControl("dropdownlist1") as DropDownList;
          d.DataSource = xxx;
            d.DataBind();
        }
      }
      

  2.   

    参考相关:
    http://www.cnblogs.com/insus/articles/1654911.html
    http://www.cnblogs.com/insus/articles/1411016.html
    http://www.cnblogs.com/insus/articles/1997458.html
    http://www.cnblogs.com/insus/archive/2011/07/04/2097059.html
      

  3.   

    protected void gridMember_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            string str = "select * from brands";
            DataSet dss = new DataSet();
            dss = dataFactory.ds(str, dss, "tb");
            if (((DropDownList)e.Row.FindControl("drop")) != null)
            {
                DropDownList drp = (DropDownList)e.Row.FindControl("drop");
                drp.DataSource = dss.Tables["tb"];
                drp.DataTextField = "brand";
                drp.DataValueField = "brandID";
                drp.DataBind();        }
        }