I have a web app (C#) which has a drop down list where users choose the week ending date for timesheets:-
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Session["ChosenWeekEnding"] = DropDownList1.SelectedValue;
RefreshTransactions(DropDownList1.SelectedValue);
Response.Redirect(Request.RawUrl, true);
}
RefreshTransactions executes the SQL query:-
protected void RefreshTransactions(string WE)
{
string WorkbenchConnection = ConfigurationManager.ConnectionStrings["WorkbenchConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(WorkbenchConnection);
con.Open();
string sqltext = "Select JobCode, ActivityCode, WorkCentreCode, TranDate FROM JobTransactions WHERE JobTranReference = '" + WE + "' AND PersonID = 3434 ";
SqlCommand cmd = new SqlCommand(sqltext,con);
SqlDataReader rdr = cmd.ExecuteReader();
GridView1.DataSource = rdr;
GridView1.DataBind();
GridView1.Visible = true;
con.Close();
}
The first time the page loads the results are valid. However using the DropDownList to change the value of WE appears to do nothing; the page remains unchanged.
I'm new to web apps using SQL, what am I missing?
What I have tried:
I've moved the Response.Redirect into various other places in the code. I've searched extensively for examples to follow; in fact what I have done was from an example.