Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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


C#
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();

        }
Posted
Updated 1-Apr-11 0:12am
v2

1 solution

I'm not sure about this, but :

C#
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900