ドロップダウンリストコントロールを設定しようとしています。 「入力」はDBです。テーブルは 'ApplicationName'であり、ランダム値が割り当てられています。SQL値がASP DropDownListコントロールに設定されない
何らかの理由で、[テスト送信]ボタンをクリックすると、何もコントロール(DropDownList1)に表示されません。
protected void TestSubmit_ServerClick(object sender, EventArgs e)
{
// Initialize the database connector.
SqlConnection connectSQL = new SqlConnection();
// Send the connection string.
connectSQL.ConnectionString = @"Data Source = localhost\SQLEXPRESS;" +
"Initial Catalog = Inputs; Integrated Security = SSPI";
try
{
// Setup our command.
SqlCommand theCommand = new SqlCommand("SELECT * FROM Inputs", connectSQL);
// Write the stored value in the text boxes.
connectSQL.Open();
SqlDataReader theReader;
theReader = theCommand.ExecuteReader();
theReader.Read();
DropDownList1.Items.Add(theReader["ApplicationName"].ToString());
theReader.Close();
connectSQL.Close();
}
catch (Exception ee)
{
MessageBox("Oopsie: " + ee);
}
1行で複数の列があり、各列がドロップダウンリストに入力される場合はどうなりますか?私の質問はここにあります:http://stackoverflow.com/questions/30310610/how-to-split-sql-query-result-to-populate-a-dropdownlist – SearchForKnowledge