GAYAN WIJEKOON

GAYAN WIJEKOON

  • NA
  • 104
  • 1.7k

Asp.net MVC without Entity Framwork

Jul 14 2018 9:46 AM
How to create Dropdown List from SQL database table column without using Entity Framwork.
I have Customer table and Branch table in my Database. CustomerID is a Foriegn Key of Branch table.
I want to create Branch Adding form(BranchId,CustomerId,Name) which has CustomerID of registered customers as a Dropdown List. 
 
  1. public class BranchModel  
  2.    {  
  3.        public int bid { getset; }  
  4.   
  5.        [Required(ErrorMessage = "Please Select Customer ID !")]  
  6.        [DisplayName("Customer ID")]  
  7.        public Nullable<int> cid { getset; }  
  8.   
  9.        [Required(ErrorMessage = "Please Enter Branch Name !")]  
  10.        [DisplayName("Branch Name")]  
  11.        public String name { getset; }  
  12.   
  13.   
  14.        [NotMapped]  
  15.        public List
    <CustomerModel>
    
     CidList { 
    getset; }  
  16.   
  17.    }  
Branch Model. 
 
how to create Controller and View 

Answers (2)