combobox1.datasource
=
xxx
//某个datatable
combobox1.displaymember
=
"显示的列"
combobox1.valuemember
=
"真正在selectedvalue中显示的内容"
使用的时候:
combobox1.selectedvalue
Stringconnectiongstring
=
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
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)