I have four DropDownLists in ASP.NET. I want to send values selected from the DropDownLists as four parameters to my stored procedure in SQL Server and when I hit the submit button, I want to get the data back from SQL Server to ASP.NET and display it in a GridView. I have tried some code. Since I am fairly new to ASP.NET, I am not sure what is wrong with my code:
protected void Button1_Click1(object sender, EventArgs e)
{
string s = "prIMDBStatistics_Submit";
SqlCommand cmd = new SqlCommand(s, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@IPAddress", SqlDbType.VarChar).Value = DropDownList5.SelectedItem.Value;
cmd.Parameters.Add("@PortNumber", SqlDbType.VarChar).Value = DropDownList2.SelectedItem.Value;
cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = DropDownList3.SelectedItem.Value;
cmd.Parameters.Add("@CacheType", SqlDbType.VarChar).Value = DropDownList4.SelectedItem.Value;
DataSet ds = new DataSet();
con.Open();
cmd.ExecuteNonQuery();
GridView1.DataSource = ds;
GridView1.DataBind();
con.Close();
}