ASP.NET GridView 内嵌 DropDownList 绑定数据

aspx页面代码:

    
        
            
            
            
            
                
                    
                    
                
            
        
    
.cs代码: 绑定下拉数据源

        public List GetDate()
        {
            List info = new List();
            using (this.context = new SDKDataContext())
            {
                var date = from c in this.context.DateInfo select c;
            }
            return info;
        }

给下拉显示初始数据

        public void BandingGridView()
        {
            using (this.context = new SDKDataContext())
            {
                var vData = from c in this.datacontext.DateInfo select c;
                this.GridView2.DataSource = vData;
                this.GridView2.DataBind();
                foreach (GridViewRow gvr in GridView2.Rows)
                {
                    DropDownList ddl = (DropDownList)gvr.FindControl("DropDownList2");
                    DateInfo info = new DateInfo();
                    info = vData[rows];
                    ddl.SelectedValue = info.Val.ToString();
                }
            }
        }



你可能感兴趣的:(ASP.Net,asp.net)