Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
C#
<select id="allTables" name="SelectedTable" >
    option value="--Select--" selected>Select </option>
    @foreach (string s in res.allTables)
    {
        <option value="@s">@s</option>
    }
</select>



JavaScript
function getTable1Columns() {
           //code? get selected table name and use it to get column names into other list.
    }
Posted
Comments
F-ES Sitecore 26-Apr-15 6:40am    
Using ajax? Using form submissions? Using SQL Server? Oracle? Access? MongoDB? ADO.Net? LinqToSQL? nHibernate? Entity Framework? Without knowing anything about the technology you are using it is impossible to answer this question, all you have shown in an html select box.

1 solution

<pre lang="c#">
string cs = ConfigurationManager.ConnectionStrings["DbConnection"].ConnectionString;
                SqlConnection con = new SqlConnection(cs);
                SqlDataAdapter da = new SqlDataAdapter("spGetAllTables", con);
                DataTable dataTable = new DataTable();

                da.Fill(dataTable);
                List<string> dt = new List<string>();
                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    dt.Add(dataTable.Rows[i][0].ToString());
                }
                RES.allTables= dt;

</string></string>


This is how i'm fetching table names. anything now?
 
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