Binding dropdownlist inside gridview edititemtemplate

前端 未结 5 1159
终归单人心
终归单人心 2020-12-14 11:53

I\'m not able to bind my dropdownlist present in edititem template . I am getting null reference when i try to access it.

My design:



        
5条回答
  •  半阙折子戏
    2020-12-14 12:39

    I do it like this. In which, Name and Id are two fields of Company object:

    HTML Code:

    
        
            
        
        
            
        
    
    

    C# code behind:

    protected IEnumerable PopulateddlCompanyEdit()
    {
        using (var bkDb = new BrickKilnDb())
        {
            return bkDb.Companies.ToList();
        }
    }
    

提交回复
热议问题