后台代码:
class="dp-c" start="1">
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- WeatherWS ws = new WeatherWS();
- IList<string> provinceDataSource = new List<string>();
-
- DataSet proDs = ws.getRegionDataset();
- ddlProvince.DataSource = proDs.Tables[0].DefaultView;
- ddlProvince.DataTextField = "RegionName";
- ddlProvince.DataValueField = "RegionID";
- ddlProvince.DataBind();
- }
- }
-
- protected void Button1_Click(object sender, EventArgs e)
- {
-
- WeatherWS ws = new WeatherWS();
- string [] wsInfo = ws.getWeather(ddlCity.SelectedValue,"");
- string result = string.Empty;
- for (int i = 0; i < wsInfo.Length; i++)
- {
- result += wsInfo[i]+"<BR/>";
- }
- Label1.Text = result;
-
- }
-
- protected void ddlProvince_SelectedIndexChanged(object sender, EventArgs e)
- {
- WeatherWS ws = new WeatherWS();
- DataSet cityDs = ws.getSupportCityDataset(ddlProvince.SelectedValue);
- ddlCity.DataSource = cityDs.Tables[0].DefaultView;
- ddlCity.DataTextField = "CityName";
- ddlCity.DataValueField = "CityID";
- ddlCity.DataBind();
- }
.aspx代码
- <asp:UpdatePanel ID="UpdatePanel1" runat="server">
- <ContentTemplate>
- <asp:DropDownList ID="ddlProvince" runat="server" AutoPostBack="True"
- onselectedindexchanged="ddlProvince_SelectedIndexChanged">
- </asp:DropDownList>
- <asp:DropDownList ID="ddlCity" runat="server">
- </asp:DropDownList>
- <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
- <br />
- <br />
- <br />
- <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
- </ContentTemplate>
- </asp:UpdatePanel>
访问速度很慢,,,...
第一步要添加Web引用
然后页面就有东西了.....webServices给的很明确了