【发布时间】:2009-07-02 16:32:49
【问题描述】:
如何将 DropDownList 上的第一项放在空白中?在 VB 中类似于 DropDownList.index[0] = ""; 我这样做了:
string StrConn = ConfigurationManager.ConnectionStrings["connSql"].ConnectionString;
SqlConnection conn = new SqlConnection(StrConn);
conn.Open();
SqlDataReader dr;
string sql;
sql = @"Select Nome From DanielPessoas";
SqlCommand cmd = new SqlCommand(sql, conn);
dr = cmd.ExecuteReader();
DropDownList1.DataSource = dr;
DropDownList1.DataTextField = "Nome";
DropDownList1.DataValueField = "Nome";
DropDownList1.DataBind();
【问题讨论】:
标签: asp.net sql-server ado.net