protected void gvItems_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            string sql = "select * from table";
            Datalb db = new Datalb();
            DataSet ds = db.Sql_s(sql);
            //DropDownList ddl = (DropDownList)e.Row.FindControl("DropDownList1");
           
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
              //  DropDownList DropDownList1 = (DropDownList)e.Row.FindControl("DropDownList1") as DropDownList;
                DropDownList ddl = e.Row.FindControl("DropDownList1") as DropDownList;
                if (ddl!=null)
                {
                    ddl.DataSource = ds.Tables[0].DefaultView;
                    ddl.DataTextField = "content";
                    ddl.DataValueField = "id";
                    ddl.DataBind();
                }
               
            }

 

 posted on 2012-07-14 10:13  纳米程序员  阅读(145)  评论(0编辑  收藏  举报