Click here to Skip to main content
15,905,874 members

Comments by teacher686 (Top 1 by date)

teacher686 30-Oct-12 5:44am View    
sir,i wanted to change the content of gridview as per the selection that i am making in my DropDownlist and that selected value i wanted to pass my stored procedure as input parameter and i wanted to pass without using button

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
string ConnectionString = ConfigurationManager.ConnectionStrings["GirishTestConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(ConnectionString);
var @class = DropDownList2.SelectedValue;
string st = @class;
con.Open();
// SqlDataReader rd;
SqlCommand cmd = new SqlCommand("DBTest2_sp", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@class", DropDownList2.SelectedValue);
SqlDataAdapter sqlda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sqlda.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
con.Close();



}