【发布时间】:2009-05-28 10:37:56
【问题描述】:
我正在使用以下代码块从 xml 文件中的内容填充页面加载时的下拉框...
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++;
}
然后我有一个按钮,我打算用它来执行搜索。
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"); }
}
搜索运行,但该死的东西返回下拉菜单中第一项的值,而不是我选择的那个。
希望我在这里遗漏了一些非常明显的东西。
谢谢
已解决
将点击功能清除为毫无意义并使用以下内容。
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()); }
}
【问题讨论】:
标签: asp.net asp.net-2.0 c#-2.0