使用linq将组合框与wpf的数据库模型绑定 [英] binding combobox with database model of wpf using linq

查看:82
本文介绍了使用linq将组合框与wpf的数据库模型绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用wpf数据库模型中的数据填充combobox ,这是我正在使用的代码.当然,它不起作用,但是因为它说的是列,所以它不知道它是什么.甚至单词defaultview.请帮助


Im trying to fill up a combobox with the data in a database model of wpf and this is the code im using. of course it is not working but because it is saying that columns it doesn''t know what it is. even the word defaultview. please help


public void bindcombo()
        {
           LogicLayer.Roles r = new LogicLayer.Roles();
           dbmodelDataContext ds = new dbmodelDataContext();@;

           cmbusertype.ItemsSource = ds.tblRoles.DefaultView;
           cmbusertype.DisplayMemberPath = ds.tblRoles.Columns["Role"].ToString();
           cmbusertype.SelectedValuePath = ds.tblRoles.Columns["RoleId"].ToString();

        }

推荐答案

我对此不确定,但是:

I''m not sure about this, but :

public void bindcombo()
{
    LogicLayer.Roles r = new LogicLayer.Roles();
    dbmodelDataContext ds = new dbmodelDataContext();@;

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


可能会起作用...

玩得开心,

爱德华


may work...

Have fun,

Eduard


这篇关于使用linq将组合框与wpf的数据库模型绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆