无法填充下拉列表。谁能帮忙,可能是一些关于我的错误的教程?我不完全了解如何填充我的数据源。对 C# 或 ASP.Net 来说很新,所以对我来说放轻松。
protected void Button1_Click(object sender, EventArgs e)
{
List<string> _newList = new List<string>();
if (TextBox1.Text != null)
{
OdbcDataReader MapResult; //Data Reader
Database db = new Database();
string lat = "";
string sql = " SELECT
informix.dbimg_mstr_rec.doc_path
FROM
informix.dbimg_mstr_rec
WHERE
informix.dbimg_mstr_rec.doc_key
= '" + TextBox1.Text + "'";
try
{
MapResult = db.ExecQuery(sql, timeOut);
if (MapResult.Read())
{
lat = MapResult["doc_path"].ToString();
DropDown1.DataSource = _newList;
DropDown1.DataTextField = "doc_path";
DropDown1.DataValueField = "doc_path";
form1.Controls.Add(DropDown1);
} //end if
MapResult.Close();
db.CloseConnection();
//end while
}//end try
catch (OdbcException ex)
{
errList.Add("[User] Error 109: " + ex.Message);
} //end catch
return;
} //end if
else
return;
}