ASP.NET中怎么从下拉列表框怎么读数据进数据库

来源:百度知道 编辑:UC知道 时间:2024/05/27 01:17:04
我现在在做登陆界面 权限的选择是个下拉列表框,我想怎么从下拉列表框中读数据进函数里。

String connectiongstring = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

SqlConnection sqlcon = new SqlConnection(connectiongstring);

string Brand = BDropDownList.SelectedValue.ToString();//下拉列表
string CmdText = "SELECT Model FROM [CarType] WHERE Brand=\'" + Brand + "\'";
SqlCommand sqlcom = new SqlCommand(CmdText, sqlcon);

try
{
sqlcon.Open();
SqlDataReader dr = sqlcom.ExecuteReader();
。。。。。。。。。。

}
catch (SqlException ex)
{
}
//清理
finally
{
if (sqlcon != null)
{
sqlcon.Close();
}
}

还有需要注意的是autopostback属性设置成true

selectedvalue吧
好像是

补充:
你要是用WEB控