DropDownList 绑定DataTable并给默认值

            string sql = @"SELECT FG_Id, FG_Name, FG_Sort, FG_IsDel FROM dbo.FirstGestation";
            DataTable FG_List = MySqlhelper.MySqlhelper.ExecuteDataTable(sql);
            FG_Id.DataSource = FG_List;
            FG_Id.DataTextField = "FG_Name";
            FG_Id.DataValueField = "FG_Id";
            FG_Id.DataBind();
            FG_Id.Items.Add(new ListItem("请选择", "", true));
            FG_Id.SelectedIndex = FG_Id.Items.Count - 1;

posted @ 2016-03-30 09:21  caijinhao  阅读(463)  评论(0编辑  收藏  举报