C#用天气预报的WebServices_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > C#用天气预报的WebServices

C#用天气预报的WebServices

 2016/5/21 5:33:32  jerrylsxu  程序员俱乐部  我要评论(0)
  • 摘要:后台代码:protectedvoidPage_Load(objectsender,EventArgse){if(!IsPostBack){WeatherWSws=newWeatherWS();IList<string>provinceDataSource=newList<string>();DataSetproDs=ws.getRegionDataset();ddlProvince.DataSource=proDs.Tables[0].DefaultView
  • 标签:C# Web Service Webservice

后台代码: 

    class="dp-c" start="1">
  1. protected void Page_Load(object sender, EventArgs e)  
  2.    {  
  3.        if (!IsPostBack)  
  4.        {  
  5.            WeatherWS ws = new WeatherWS();  
  6.            IList<string> provinceDataSource = new List<string>();  
  7.   
  8.            DataSet proDs = ws.getRegionDataset();  
  9.            ddlProvince.DataSource = proDs.Tables[0].DefaultView;  
  10.            ddlProvince.DataTextField = "RegionName";  
  11.            ddlProvince.DataValueField = "RegionID";  
  12.            ddlProvince.DataBind();  
  13.        }  
  14.    }  
  15.   
  16.    protected void Button1_Click(object sender, EventArgs e)  
  17.    {  
  18.   
  19.        WeatherWS ws = new WeatherWS();  
  20.        string [] wsInfo = ws.getWeather(ddlCity.SelectedValue,"");  
  21.        string result = string.Empty;  
  22.        for (int i = 0; i < wsInfo.Length; i++)  
  23.        {  
  24.            result += wsInfo[i]+"<BR/>";  
  25.        }  
  26.        Label1.Text = result;  
  27.   
  28.    }  
  29.   
  30.    protected void ddlProvince_SelectedIndexChanged(object sender, EventArgs e)  
  31.    {  
  32.        WeatherWS ws = new WeatherWS();  
  33.        DataSet cityDs = ws.getSupportCityDataset(ddlProvince.SelectedValue);  
  34.        ddlCity.DataSource = cityDs.Tables[0].DefaultView;  
  35.        ddlCity.DataTextField = "CityName";  
  36.        ddlCity.DataValueField = "CityID";  
  37.        ddlCity.DataBind();  
  38.    }  

 .aspx代码 

  1. <asp:UpdatePanel ID="UpdatePanel1" runat="server">  
  2.                 <ContentTemplate>  
  3.                     <asp:DropDownList ID="ddlProvince" runat="server" AutoPostBack="True"   
  4.                         onselectedindexchanged="ddlProvince_SelectedIndexChanged">  
  5.                     </asp:DropDownList>  
  6.                     <asp:DropDownList ID="ddlCity" runat="server">  
  7.                     </asp:DropDownList>  
  8.                     <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />  
  9.                     <br />  
  10.                     <br />  
  11.                     <br />  
  12.                     <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>  
  13.                 </ContentTemplate>  
  14.             </asp:UpdatePanel>  

 访问速度很慢,,,... 

第一步要添加Web引用

  

 

然后页面就有东西了.....webServices给的很明确了

发表评论
用户名: 匿名