标签:ebs sed 天气 datarow 图片 stat items source ble
1.创建服务引用
例如:天气预报
2.在代码添加引用空间
1 TvProgram.ChinaTVprogramWebService tp = new TvProgram.ChinaTVprogramWebService(); 2 DataSet ds= tp.getAreaDataSet();
3.引用具体方法
1 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) 2 { 3 ComboBox cb = (ComboBox)sender; 4 if(comboBox1.SelectedIndex>0) 5 { 6 7 int num= Convert.ToInt32(cb.SelectedValue.ToString()); 8 9 TvProgram.ChinaTVprogramWebService tp = new TvProgram.ChinaTVprogramWebService(); 10 DataSet ds = tp.getTVstationDataSet(num); 11 comboBox2.DataSource = ds.Tables[0]; 12 comboBox2.DisplayMember = "tvStationName"; 13 comboBox2.ValueMember = "tvStationID"; 14 15 } 16 }
返回的xml用两种处理方法
//DataRow[] dt = ds.Tables[0].Select(); //for (int i = 3; i < dt.Length; i++) //{ // Text = dt[i]["Area"].ToString(); // Value = Convert.ToInt32(dt[i]["areaID"].ToString()); // comboBox1.Items.Add(Text); //}
comboBox1.DataSource = ds.Tables[0]; comboBox1.DisplayMember = "Area"; comboBox1.ValueMember = "areaID";
标签:ebs sed 天气 datarow 图片 stat items source ble
原文地址:http://www.cnblogs.com/yyl001/p/7991288.html