开发者

Binding Combo box with wpf using linq

My first time using wpf and linq and im comfusing everything. can anyone help me here? Im trying to fill the combobox cmbusertype with all the data in the table using the dbmodel of wpf but the defaultView and columns it is saying that it doesn't contain a definition for them.

    public void bindcombo()
    {
    开发者_开发技巧   LogicLayer.Roles r = new LogicLayer.Roles();
       dbmodelDataContext ds = new dbmodelDataContext();
       //return ds.tblusers.AsEnumerable();


        cmbusertype.ItemsSource = ds.tblRoles.DefaultView;

        cmbusertype.DisplayMemberPath = ds.tblRoles.Columns["Role"].ToString();

        cmbusertype.SelectedValuePath = ds.tblRoles.Columns["RoleId"].ToString();


    }


Try out the follow code and if you have any other query comment it here:

public void bindcombo()
        {
           LogicLayer.Roles r = new LogicLayer.Roles();
           dbmodelDataContext ds = new dbmodelDataContext();
           //return ds.tblusers.AsEnumerable(); 

            cmbusertype.ItemsSource = ds.tblRoles.DefaultView;    
            cmbusertype.DisplayMemberPath = "Role";    
            cmbusertype.SelectedValuePath = "RoleID";
        }

if this is the answer you are looking for than do mark it as an answer

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜