を追加最初のフィールド(テーブル)のすべてのテーブルをバインドし、グリッドビュー内のドロップダウンリスト内の各テーブルの各列をバインドし、2番目のドロップダウンリスト内のすべての新しい列をバインドするクリックイベントでグリッドビューを表示するこのグリッドビューが3列(テーブル、列、new_columns)</p> <p><img src="https://i.stack.imgur.com/dkvIV.png" alt="enter image description here"></p> <p>私が欲しいを表示することになっている私は自分のWebアプリケーションでのGridViewを持って</p> <p>をGridViewのデータ(Webアプリケーション)C#
ここは電子コード
DataTable test = new DataTable();
DataTable _dbtest = new DataTable();
list_of_table_of_old_database = db.Select("", "", "", "", "", "", "", "", "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.tables WHERE TABLE_SCHEMA = '" + old_database.Text.Trim() + "' ", "");
list_of_table_of_current_database = db.Select("", "", "", "", "", "", "", "", "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.tables WHERE TABLE_SCHEMA = '" + new_database.Text.Trim() + "' ", "");
DataView view = new DataView(list_of_table_of_old_database);
DataTable dtTable = new DataTable();
test = db.Select("", "", "", "", "", "", "", "", "select distinct k.table1 from (SELECT TABLE_NAME as table1 FROM INFORMATION_SCHEMA.tables WHERE TABLE_SCHEMA = '" + old_database.Text.Trim() + "') as k INNER JOIN (SELECT TABLE_NAME as table2 FROM INFORMATION_SCHEMA.tables WHERE TABLE_SCHEMA = '" + new_database.Text.Trim() + "')as a;", "");
DropDownList3.Items.Clear();
DropDownList3.Items.Insert(0, "--select--");
DataTable dt = new DataTable();
for (int i = 0; i < test.Rows.Count; i++)
{
_dbtest = db.Select("", "", "", "", "", "", "", "", "select a.fieldname from (SELECT COLUMN_NAME as fieldname FROM INFORMATION_SCHEMA.columns WHERE TABLE_SCHEMA = '" + old_database.Text.Trim() + "' and TABLE_NAME = '" + test.Rows[i][0].ToString() + "') as A LEFT JOIN (SELECT COLUMN_NAME as fieldname FROM INFORMATION_SCHEMA.columns WHERE TABLE_SCHEMA = '" + new_database.Text.Trim() + "' and TABLE_NAME = '" + test.Rows[i][0].ToString() + "') B on (A.fieldname = B.fieldname) where B.fieldname is null ", "");
if (_dbtest.Rows.Count > 0)
{
//here i want to display all tables in the gridview row by row (test.Rows[i][0].ToString())
}
// and i want to bind all columns (_dbtest) of each tables inside the loop in first dropdownlist in gridview
// and same columns (_dbtest) of each tables inside the loop in second dropdownlist in gridview
}
私はループを実行していながら、GridViewのデータをバインドするいくつかの方法を見つけたいので、私は、各フィールドに
を適切なデータを与えることができ、これは、HTMLコード
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
Height="237px" Width="632px" onrowdatabound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField FooterText="tables" HeaderText="tables">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField FooterText="columns" HeaderText="columns">
<ItemTemplate>
<asp:DropDownList ID="ddlcolumns" runat="server"
Height="16px" Width="181px">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField FooterText="vms-columns" HeaderText="vms-columns">
<ItemTemplate>
<asp:DropDownList ID="ddl_vms_columns" runat="server"
Height="20px" Width="153px">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
です
最後にグリッドビューのすべてのテーブルとそのテーブルの各列が表示されます