Click here to Skip to main content
15,895,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi I have 2 class in code first
C#
public class Groups
    {
        public Groups() { }
        [Key]
        public int GroupID { get; set; }
        [Required]
        public string  GroupName { get; set; }
        public string GroupDescription { get; set; }

        public virtual ICollection<Users> Users { get; set; }
    }

C#
public class Users
    {
        public Users() { }
        [Key]
        public int UserId { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string UserName { get; set; }
        [Required]
        public Int64 DocID { get; set; }
        public string Description { get; set; }
        public int GroupID { get; set; }
        [ForeignKey("GroupID")]
        public virtual Groups Groups { get; set; }
    }


in winform I add datagridview and select datasource to table Users, when I try editing users the GroupID Column not see with ComboBox! how can used this Colmn with combobox to select group??
and so why in datagridview show 2 column GroupID and Groups?
Posted
Comments
sreeyush sudhakaran 9-Aug-15 7:07am    
refer https://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.schema.foreignkeyattribute(v=vs.110).aspx
farazpo 11-Aug-15 5:09am    
hi my friend I know this link and class and if you see my source I do that! but I want make gridview dropdown with forigen key!!

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