我有兩個下拉列表中的Web窗體..他們兩個我用下面的代碼來綁定與sql..but每當我試圖結合第二個下拉與同method..it的給錯誤列表.. 我使用的代碼:在兩個下拉列表中同時訪問數據的問題
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ddlPropertyType.AppendDataBoundItems = true;
String strConnString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
String strQuery = "select ID, PropertyName from PropertyType";
SqlConnection con = new SqlConnection(strConnString);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = strQuery;
cmd.Connection = con;
try
{
con.Open();
ddlPropertyType.DataSource = cmd.ExecuteReader();
ddlPropertyType.DataTextField = "PropertyName";
ddlPropertyType.DataValueField = "ID";
ddlPropertyType.DataBind();
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
con.Dispose();
}
}
}
上午取數據來自兩個tables..say – Prasad 2011-03-17 11:08:02
我從兩個表中獲取數據..如果我在第一個ddl中選擇狀態,我需要第二個ddl中的所有城市名稱..如何在代碼同時獲取兩個表時使用此代碼.. – Prasad 2011-03-17 11:09:19