还有这个是595871讨论.net的QQ群组,欢迎高手加入
在发送请求中输入csdn asp.net

解决方案 »

  1.   

    you cannot declare DDL_MZ  this way, since each row of DataGrid has one dropdownlistyou need to access it in some event handler for the DataGrid like thisDropDownList ddl = (DropDownList)DataGrid1.Items[DataGrid1.EditItemIndex].FindControl("DDL_MZ ");
      

  2.   

    思归
    您的意思是我不能在页面代码的模板列中声明dropdownlist是吗?
    您说datagrid中每行都包含一个dropdownlist,那我如何将数据源绑定到dropdownlist中去?
    谢谢
      

  3.   

    seehttp://aspnet.4guysfromrolla.com/articles/080702-1.2.aspx
      

  4.   

    private void BindDDL(string TableName,string DDLSQLstring)
    {
    SqlConnection myConnection = new SqlConnection("Data Source=localhost;User ID=sa;Password=sa;Initial Catalog=rcdatabase");
    SqlDataAdapter myCommand = new SqlDataAdapter(DDLSQLstring, myConnection); DataSet ds = new DataSet();
    myCommand.Fill(ds, TableName);

    DropDownList DDL_General;
    DDL_General = (DropDownList)MyDataGrid.Items;
    [MyDataGrid.EditItemIndex].FindControl("DDL_MZ ").DataSource=ds.Tables[TableName].DefaultView;
    [MyDataGrid.EditItemIndex].FindControl("DDL_MZ ").DataBind();
    }
    这样好像不行,请思归大哥哥明示,在页面代码中还用自定义dropdownlist吗?在后置代码中如何绑定数据源?