您的位置:首页 > 编程语言 > ASP

aspnet企业级开发:显示天气预报

2012-09-19 23:51 267 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class _3_6 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack){
GridView1.DataSource = null;
GridView1.DataBind();
}
//开始时没有数据,但也要空绑定,来显示EmptyDataText的内容,不然不能显示
}
protected void Button1_Click(object sender, EventArgs e)
{
cn.com.webxml.www.WeatherWebService ser = new cn.com.webxml.www.WeatherWebService();
/*右键项目,选择"添加web引用....",然后粘贴url: http://www.webxml.com.cn/WebServices/WeatherWebService.asmx 添加天气预报web服务,这样便可引用上述代码
*/
string[] temp=ser.getWeatherbyCityName(TextBox1.Text);
//字符串数组被视作一列来绑定
GridView1.DataSource = temp;
GridView1.DataBind();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: