本文介绍了如何获取表名的选定值以填充子下拉列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<select id="allTables" name="SelectedTable" >
option value="--Select--" selected>Select </option>
@foreach (string s in res.allTables)
{
<option value="@s">@s</option>
}
</select>
function getTable1Columns() {
//code? get selected table name and use it to get column names into other list.
}
推荐答案
<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?
这篇关于如何获取表名的选定值以填充子下拉列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!