I'm using the following chunks of code to populate a drop down box on page load from content in an xml file...
foreach (System.Xml.XmlNode item in root.SelectNodes(@"/markers/marker"))
{
string tmpValue = item.Attributes["location"].Value + "#" + item.Attributes["lat"].Value + "#" + item.Attributes["lng"].Value;
destination.Items.Add(new ListItem(item.Attributes["location"].Value, tmpValue));
tmpNCount++;
}
I then have a button which I planned to use to perform a search.
protected void qsearch_Click(object sender, EventArgs e) {
try
{
string httpPath = Convert.ToString(UrlMaker.httpURL());
//sysmessage.Text = "TEST" + destination.SelectedValue.ToString();
string[] Split = destination.SelectedValue.ToString().Split(new Char[] { '#' });
string tmpLocation = Convert.ToString(Split[0]);
string tmpLat = Convert.ToString(Split[1]);
string tmpLon = Convert.ToString(Split[2]);
string tmpRad = radius.SelectedValue.ToString();
Response.Redirect(httpPath + "search.aspx?func=longlat&country=gbr&lng="+tmpLon+"&lat="+tmpLat+"&rad="+tmpRad+"&txt="+tmpLocation+"&test=1");
}
catch(Exception ex) { Response.Write("Error on Redirect"); }
}
The Search runs but the bloody thing returns the value of the first item in the dropdown rather than the one I'm selecting.
I'm hopefully missing something really obvious here.
Thanks
Solved
Wiped out the click function as pointless and used the following.
if (IsPostBack)
{
try
{
string fdata = Request.Form["dest"];
string[] Split = fdata.ToString().Split(new Char[] { '#' });
string tmpLocation = Convert.ToString(Split[0]);
string tmpLat = Convert.ToString(Split[1]);
string tmpLon = Convert.ToString(Split[2]);
string tmpRad = radius.SelectedValue.ToString();
Response.Redirect(httpPath + "search.aspx?func=longlat&country=gbr&lng=" + tmpLon + "&lat=" + tmpLat + "&rad=" + tmpRad + "&txt=" + tmpLocation + "&test=1");
}
catch(Exception ex) { Response.Write("Error on Redirect" + ex.ToString()); }
}