我的ASP网站中的下拉列表出现问题
好的,我想做什么?
我想从我的下拉列表中选择一个项目,然后激活一些代码,例如当我点击Hek时,它会在我点击Dodixie之后加载正确的信息,当页面刷新但没有加载新值,当我点击名称时,下拉文本再次默认为Jita。
这里有一些代码:
前端:
<asp:DropDownList ID="stationSelect" runat="server" CssClass="OverviewText" AutoPostBack="true" OnSelectedIndexChanged="stationSelect_SelectedIndexChanged" >
<asp:ListItem value="0">Jita</asp:ListItem>
<asp:ListItem value="1">Hek</asp:ListItem>
<asp:ListItem value="2">Dodxie</asp:ListItem>
<asp:ListItem value="3"> Armar</asp:ListItem>
<asp:ListItem value="4">Rens</asp:ListItem>
</asp:DropDownList>
后端:
protected void stationSelect_SelectedIndexChanged(object sender, EventArgs e)
{
stationSelect.ClearSelection();
stationSelect.SelectedIndex = stationSelect.Items.IndexOf(stationSelect.Items.FindByValue("0"));
{
string OrePriceA = "http://api.eve-central.com/api/marketstat?typeid=34&minQ=1&typeid=35&minQ=1&typeid=36&minQ=1&typeid=37&minQ=1&typeid=38&minQ=1&typeid=39&minQ=1&typeid=40&minQ=1&typeid=11399&minQ=1&usesystem=30002187";
XmlDocument xdoc = new XmlDocument();
xdoc.Load(OrePriceA);
TriPrAmarB.Text = GetStat(xdoc, 34, TranType.Buy, StatType.Max);
TriPrAmarS.Text = GetStat(xdoc, 34, TranType.Sell, StatType.Max);
PyrPrAmarB.Text = GetStat(xdoc, 35, TranType.Buy, StatType.Max);
PyrPrAmarS.Text = GetStat(xdoc, 35, TranType.Sell, StatType.Max);
MexPrAmarB.Text = GetStat(xdoc, 36, TranType.Buy, StatType.Max);
MexPrAmarS.Text = GetStat(xdoc, 36, TranType.Sell, StatType.Max);
IsoPrAmarB.Text = GetStat(xdoc, 37, TranType.Buy, StatType.Max);
IsoPrAmarS.Text = GetStat(xdoc, 37, TranType.Sell, StatType.Max);
NocPrAmarB.Text = GetStat(xdoc, 38, TranType.Buy, StatType.Max);
NocPrAmarS.Text = GetStat(xdoc, 38, TranType.Sell, StatType.Max);
ZydPrAmarB.Text = GetStat(xdoc, 39, TranType.Buy, StatType.Max);
ZydPrAmarS.Text = GetStat(xdoc, 39, TranType.Sell, StatType.Max);
MegPrAmarB.Text = GetStat(xdoc, 40, TranType.Buy, StatType.Max);
MegPrAmarS.Text = GetStat(xdoc, 40, TranType.Sell, StatType.Max);
MorPrAmarB.Text = GetStat(xdoc, 11399, TranType.Buy, StatType.Max);
MorPrAmarS.Text = GetStat(xdoc, 11399, TranType.Sell, StatType.Max);
};
stationSelect.ClearSelection();
stationSelect.SelectedIndex = stationSelect.Items.IndexOf(stationSelect.Items.FindByValue("1"));
{
string OrePriceH = "http://api.eve-central.com/api/marketstat?typeid=34&minQ=1&typeid=35&minQ=1&typeid=36&minQ=1&typeid=37&minQ=1&typeid=38&minQ=1&typeid=39&minQ=1&typeid=40&minQ=1&typeid=11399&minQ=1&usesystem=30003394";
XmlDocument xdocH = new XmlDocument();
xdocH.Load(OrePriceH);
TriPrAmarB.Text = GetStat(xdocH, 34, TranTypeH.Buy, StatTypeH.Max);
TriPrAmarS.Text = GetStat(xdocH, 34, TranTypeH.Sell, StatTypeH.Max);
PyrPrAmarB.Text = GetStat(xdocH, 35, TranTypeH.Buy, StatTypeH.Max);
PyrPrAmarS.Text = GetStat(xdocH, 35, TranTypeH.Sell, StatTypeH.Max);
MexPrAmarB.Text = GetStat(xdocH, 36, TranTypeH.Buy, StatTypeH.Max);
MexPrAmarS.Text = GetStat(xdocH, 36, TranTypeH.Sell, StatTypeH.Max);
IsoPrAmarB.Text = GetStat(xdocH, 37, TranTypeH.Buy, StatTypeH.Max);
IsoPrAmarS.Text = GetStat(xdocH, 37, TranTypeH.Sell, StatTypeH.Max);
NocPrAmarB.Text = GetStat(xdocH, 38, TranTypeH.Buy, StatTypeH.Max);
NocPrAmarS.Text = GetStat(xdocH, 38, TranTypeH.Sell, StatTypeH.Max);
ZydPrAmarB.Text = GetStat(xdocH, 39, TranTypeH.Buy, StatTypeH.Max);
ZydPrAmarS.Text = GetStat(xdocH, 39, TranTypeH.Sell, StatTypeH.Max);
MegPrAmarB.Text = GetStat(xdocH, 40, TranTypeH.Buy, StatTypeH.Max);
MegPrAmarS.Text = GetStat(xdocH, 40, TranTypeH.Sell, StatTypeH.Max);
MorPrAmarB.Text = GetStat(xdocH, 11399, TranTypeH.Buy, StatTypeH.Max);
MorPrAmarS.Text = GetStat(xdocH, 11399, TranTypeH.Sell, StatTypeH.Max);
};
stationSelect.ClearSelection();
// ENTER TEXT HERE
{
string OrePriceD = "http://api.eve-central.com/api/marketstat?typeid=34&minQ=1&typeid=35&minQ=1&typeid=36&minQ=1&typeid=37&minQ=1&typeid=38&minQ=1&typeid=39&minQ=1&typeid=40&minQ=1&typeid=11399&minQ=1&usesystem=30002659";
XmlDocument xdocD = new XmlDocument();
xdocD.Load(OrePriceD);
TriPrAmarB.Text = GetStat(xdocD, 34, TranTypeD.Buy, StatTypeD.Max);
TriPrAmarS.Text = GetStat(xdocD, 34, TranTypeD.Sell, StatTypeD.Max);
PyrPrAmarB.Text = GetStat(xdocD, 35, TranTypeD.Buy, StatTypeD.Max);
PyrPrAmarS.Text = GetStat(xdocD, 35, TranTypeD.Sell, StatTypeD.Max);
MexPrAmarB.Text = GetStat(xdocD, 36, TranTypeD.Buy, StatTypeD.Max);
MexPrAmarS.Text = GetStat(xdocD, 36, TranTypeD.Sell, StatTypeD.Max);
IsoPrAmarB.Text = GetStat(xdocD, 37, TranTypeD.Buy, StatTypeD.Max);
IsoPrAmarS.Text = GetStat(xdocD, 37, TranTypeD.Sell, StatTypeD.Max);
NocPrAmarB.Text = GetStat(xdocD, 38, TranTypeD.Buy, StatTypeD.Max);
NocPrAmarS.Text = GetStat(xdocD, 38, TranTypeD.Sell, StatTypeD.Max);
ZydPrAmarB.Text = GetStat(xdocD, 39, TranTypeD.Buy, StatTypeD.Max);
ZydPrAmarS.Text = GetStat(xdocD, 39, TranTypeD.Sell, StatTypeD.Max);
MegPrAmarB.Text = GetStat(xdocD, 40, TranTypeD.Buy, StatTypeD.Max);
MegPrAmarS.Text = GetStat(xdocD, 40, TranTypeD.Sell, StatTypeD.Max);
MorPrAmarB.Text = GetStat(xdocD, 11399, TranTypeD.Buy, StatTypeD.Max);
MorPrAmarS.Text = GetStat(xdocD, 11399, TranTypeD.Sell, StatTypeD.Max);
};
stationSelect.ClearSelection();
}
// Dodixie
enum TranTypeD { Buy, Sell, All };
enum StatTypeD { Volume, Avg, Max, Min, StdDev, Median, Percentile };
private static string GetStat(XmlDocument xdocD, int id, TranTypeD tranType, StatTypeD statType)
{
string xpath = string.Format("/evec_api/marketstat/type[@id = {0}]/{1}/{2}",
id, tranType.ToString().ToLower(), statType.ToString().ToLower());
return GetFirstElementText(xdocD, xpath);
}
// Hek
enum TranTypeH { Buy, Sell, All };
enum StatTypeH { Volume, Avg, Max, Min, StdDev, Median, Percentile };
private static string GetStat(XmlDocument xdocH, int id, TranTypeH tranType, StatTypeH statType)
{
string xpath = string.Format("/evec_api/marketstat/type[@id = {0}]/{1}/{2}",
id, tranType.ToString().ToLower(), statType.ToString().ToLower());
return GetFirstElementText(xdocH, xpath);
}
// Jita
enum TranType { Buy, Sell, All };
enum StatType { Volume, Avg, Max, Min, StdDev, Median, Percentile };
private static string GetStat(XmlDocument xdoc, int id, TranType tranType, StatType statType)
{
string xpath = string.Format("/evec_api/marketstat/type[@id = {0}]/{1}/{2}",
id, tranType.ToString().ToLower(), statType.ToString().ToLower());
return GetFirstElementText(xdoc, xpath);
}
给你一个更好主意的图片:
答案 0 :(得分:2)
如果我理解正确,您需要将代码更改为:
protected void stationSelect_SelectedIndexChanged(object sender, EventArgs e)
{
if(stationSelect.SelectedValue == "0")
{
string OrePriceA = "http://api.eve-central.com/api/marketstat?typeid=34&minQ=1&typeid=35&minQ=1&typeid=36&minQ=1&typeid=37&minQ=1&typeid=38&minQ=1&typeid=39&minQ=1&typeid=40&minQ=1&typeid=11399&minQ=1&usesystem=30002187";
XmlDocument xdoc = new XmlDocument();
xdoc.Load(OrePriceA);
TriPrAmarB.Text = GetStat(xdoc, 34, TranType.Buy, StatType.Max);
TriPrAmarS.Text = GetStat(xdoc, 34, TranType.Sell, StatType.Max);
PyrPrAmarB.Text = GetStat(xdoc, 35, TranType.Buy, StatType.Max);
PyrPrAmarS.Text = GetStat(xdoc, 35, TranType.Sell, StatType.Max);
MexPrAmarB.Text = GetStat(xdoc, 36, TranType.Buy, StatType.Max);
MexPrAmarS.Text = GetStat(xdoc, 36, TranType.Sell, StatType.Max);
IsoPrAmarB.Text = GetStat(xdoc, 37, TranType.Buy, StatType.Max);
IsoPrAmarS.Text = GetStat(xdoc, 37, TranType.Sell, StatType.Max);
NocPrAmarB.Text = GetStat(xdoc, 38, TranType.Buy, StatType.Max);
NocPrAmarS.Text = GetStat(xdoc, 38, TranType.Sell, StatType.Max);
ZydPrAmarB.Text = GetStat(xdoc, 39, TranType.Buy, StatType.Max);
ZydPrAmarS.Text = GetStat(xdoc, 39, TranType.Sell, StatType.Max);
MegPrAmarB.Text = GetStat(xdoc, 40, TranType.Buy, StatType.Max);
MegPrAmarS.Text = GetStat(xdoc, 40, TranType.Sell, StatType.Max);
MorPrAmarB.Text = GetStat(xdoc, 11399, TranType.Buy, StatType.Max);
MorPrAmarS.Text = GetStat(xdoc, 11399, TranType.Sell, StatType.Max);
}
if(stationSelect.SelectedValue == "1")
{
string OrePriceH = "http://api.eve-central.com/api/marketstat?typeid=34&minQ=1&typeid=35&minQ=1&typeid=36&minQ=1&typeid=37&minQ=1&typeid=38&minQ=1&typeid=39&minQ=1&typeid=40&minQ=1&typeid=11399&minQ=1&usesystem=30003394";
XmlDocument xdocH = new XmlDocument();
xdocH.Load(OrePriceH);
TriPrAmarB.Text = GetStat(xdocH, 34, TranTypeH.Buy, StatTypeH.Max);
TriPrAmarS.Text = GetStat(xdocH, 34, TranTypeH.Sell, StatTypeH.Max);
PyrPrAmarB.Text = GetStat(xdocH, 35, TranTypeH.Buy, StatTypeH.Max);
PyrPrAmarS.Text = GetStat(xdocH, 35, TranTypeH.Sell, StatTypeH.Max);
MexPrAmarB.Text = GetStat(xdocH, 36, TranTypeH.Buy, StatTypeH.Max);
MexPrAmarS.Text = GetStat(xdocH, 36, TranTypeH.Sell, StatTypeH.Max);
IsoPrAmarB.Text = GetStat(xdocH, 37, TranTypeH.Buy, StatTypeH.Max);
IsoPrAmarS.Text = GetStat(xdocH, 37, TranTypeH.Sell, StatTypeH.Max);
NocPrAmarB.Text = GetStat(xdocH, 38, TranTypeH.Buy, StatTypeH.Max);
NocPrAmarS.Text = GetStat(xdocH, 38, TranTypeH.Sell, StatTypeH.Max);
ZydPrAmarB.Text = GetStat(xdocH, 39, TranTypeH.Buy, StatTypeH.Max);
ZydPrAmarS.Text = GetStat(xdocH, 39, TranTypeH.Sell, StatTypeH.Max);
MegPrAmarB.Text = GetStat(xdocH, 40, TranTypeH.Buy, StatTypeH.Max);
MegPrAmarS.Text = GetStat(xdocH, 40, TranTypeH.Sell, StatTypeH.Max);
MorPrAmarB.Text = GetStat(xdocH, 11399, TranTypeH.Buy, StatTypeH.Max);
MorPrAmarS.Text = GetStat(xdocH, 11399, TranTypeH.Sell, StatTypeH.Max);
}
if(stationSelect.SelectedValue == "2")
{
string OrePriceD = "http://api.eve-central.com/api/marketstat?typeid=34&minQ=1&typeid=35&minQ=1&typeid=36&minQ=1&typeid=37&minQ=1&typeid=38&minQ=1&typeid=39&minQ=1&typeid=40&minQ=1&typeid=11399&minQ=1&usesystem=30002659";
XmlDocument xdocD = new XmlDocument();
xdocD.Load(OrePriceD);
TriPrAmarB.Text = GetStat(xdocD, 34, TranTypeD.Buy, StatTypeD.Max);
TriPrAmarS.Text = GetStat(xdocD, 34, TranTypeD.Sell, StatTypeD.Max);
PyrPrAmarB.Text = GetStat(xdocD, 35, TranTypeD.Buy, StatTypeD.Max);
PyrPrAmarS.Text = GetStat(xdocD, 35, TranTypeD.Sell, StatTypeD.Max);
MexPrAmarB.Text = GetStat(xdocD, 36, TranTypeD.Buy, StatTypeD.Max);
MexPrAmarS.Text = GetStat(xdocD, 36, TranTypeD.Sell, StatTypeD.Max);
IsoPrAmarB.Text = GetStat(xdocD, 37, TranTypeD.Buy, StatTypeD.Max);
IsoPrAmarS.Text = GetStat(xdocD, 37, TranTypeD.Sell, StatTypeD.Max);
NocPrAmarB.Text = GetStat(xdocD, 38, TranTypeD.Buy, StatTypeD.Max);
NocPrAmarS.Text = GetStat(xdocD, 38, TranTypeD.Sell, StatTypeD.Max);
ZydPrAmarB.Text = GetStat(xdocD, 39, TranTypeD.Buy, StatTypeD.Max);
ZydPrAmarS.Text = GetStat(xdocD, 39, TranTypeD.Sell, StatTypeD.Max);
MegPrAmarB.Text = GetStat(xdocD, 40, TranTypeD.Buy, StatTypeD.Max);
MegPrAmarS.Text = GetStat(xdocD, 40, TranTypeD.Sell, StatTypeD.Max);
MorPrAmarB.Text = GetStat(xdocD, 11399, TranTypeD.Buy, StatTypeD.Max);
MorPrAmarS.Text = GetStat(xdocD, 11399, TranTypeD.Sell, StatTypeD.Max);
}
}