Click here to Skip to main content
16,016,535 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more: , +
i want to get all column names in listbox from database based on table name selection in dropdownlist using asp.net mvc5

What I have tried:

public List<string> GetTableNames()
     {
         using (var Context = new MCPEntities())
         {
             FieldInfo[] mytables = Context.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
             List<string> tbllistname = new List<string>();
             foreach (var item in mytables)
             {
                 tbllistname.Add(item.Name.Split('<', '>')[1]);
             }
             return tbllistname;
           }
      }
Posted
Updated 30-May-17 2:53am

1 solution

 
Share this answer
 
Comments
Maciej Los 30-May-17 14:12pm    
Good one!

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