如下代码。GridView1绑定到SqlDataSource1,当SelectedIndexChanged动作触发这个代码后,我用SQL的事件探查器没有发现SQL中有SELECT动作。GridView1也没有显示~~请问这是啥问题- - 
    protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) 
    { 
        SqlDataSource1.SelectCommand = "SELECT account,gamename,lv,job,phone FROM userinfo WHERE grid = '"+DropDownList2.SelectedValue +"'"; 
        GridView1.DataSourceID = "SqlDataSource1"; 
        GridView1.DataBind(); 
    }

解决方案 »

  1.   

    是否有设置AutoPostBack属性为true?
      

  2.   

    你的DropDownList放的是什么东西?
    where后面习惯上是DropDownList2.SelectedItem.Text
      

  3.   

    当然不行
    给你发个类似的,你修改下,需要把查出来的数据放进datatable或者dataset中,然后绑定才行。
    string connectionString=System.Configuration.ConfigurationManager.ConnectionStrings["ConnectString"].ConnectionString;
            SqlConnection connection = new SqlConnection(connectionString);
            connection.Open();
            SqlCommand command = new SqlCommand("SELECT * from tablename", connection);
            SqlDataAdapter ada = new SqlDataAdapter(command);
            DataTable dt = new DataTable();
            ada.Fill(dt);
            gridView.DataSource = dt;
            gridView.DataBind();
            connection.Close();
      

  4.   

            SqlConnection connection = new SqlConnection("Server=(local);Integrated Security=SSPI;database=gcmx"); 
            connection.Open();
            SqlCommand command = new SqlCommand("SELECT account,gamename,lv,job,phone FROM userinfo WHERE grid = '" + DropDownList2.SelectedValue + "'", connection);
            SqlDataAdapter ada = new SqlDataAdapter(command);
            DataTable dt = new DataTable();
            ada.Fill(dt);
            GridView1.DataSource = dt;
            GridView1.DataBind();
            connection.Close();这样还是不行啊~~GRIDVIEW看不见......