I've got a DropDown which I populate from a database. When an item is selected I want to redirect to another page with the selected id, but the problem is it passes "1" no matter what was selected.
protected void Page_Load(object sender, EventArgs e)
{
Populate();
}
public void Populate()
{
OleDbConnection con = new OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0; " +
"Data Source=" + Server.MapPath("connect.mdb"));
con.Open();
string strQuery = "SELECT A_ID, Title_eng FROM C_about";
OleDbCommand cmd = new OleDbCommand(strQuery, con);
OleDbDataReader reader = cmd.ExecuteReader();
titleSelection.DataSource = reader;
titleSelection.DataValueField = "A_ID";
titleSelection.DataTextField = "Title_eng";
titleSelection.DataBind();
con.Close();
con.Dispose();
}
protected void titleSelection_SelectedIndexChanged(object sender, EventArgs e)
{
string A_ID = titleSelection.SelectedValue.ToString();
Response.Redirect("aboutEdit.aspx?A_ID=" + A_ID);
}
this is the view source:
Title:<br />
<select name="titleSelection" onchange="javascript:setTimeout('__doPostBack(\'titleSelection\',\'\')', 0)" id="titleSelection">
<option selected="selected" value="1">WHO WE ARE</option>
<option value="2">WHAT WE DO</option>
<option value="3">Permanent Placements</option>
<option value="4">Temporary staff</option>
<option value="5">Training & Development</option>
<option value="6">CV Writing Tips</option>
<option value="7">Jobs Titles & Descriptions</option>
<option value="8">Looking for Talent?</option>
<option value="9">Looking for a Job</option>
<option value="10">Register</option>