我有两个下拉列表中的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