C# QQ weather

6526 ワード

/// <summary>
    /// 2011-06-16  
    /// </summary>
    public partial class QQweather : System.Web.UI.Page
    {

        public string selectcity = "1";
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);
            HttpWebRequest req = (HttpWebRequest)WebRequest.CreateDefault(new Uri("https://www.dusystem.com/QQweather.aspx"));
            req.Method = "GET";
            HttpWebResponse res = (HttpWebResponse)req.GetResponse();
            selectcity = DropDownList1.SelectedValue.ToString();
            if (!IsPostBack)
            {

                this.DropDownList1.DataSource = CreateDataSource();
                DropDownList1.DataTextField = "WeatherTextField";
                DropDownList1.DataValueField = "WeatherValueField";

                // Bind the data to the control.
                DropDownList1.DataBind();

                // Set the default selected item, if desired.
                DropDownList1.SelectedIndex = 0;
                selectcity = @"1";
            }


        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);
            HttpWebRequest req = (HttpWebRequest)WebRequest.CreateDefault(new Uri("https://www.dusystem.com/QQweather.aspx"));
            req.Method = "GET";
            HttpWebResponse res = (HttpWebResponse)req.GetResponse();
            selectcity = DropDownList1.SelectedValue.ToString();
        }
        /// <summary>
        /// <%# selectcity%>
        /// </summary>
        /// <returns></returns>
        ICollection CreateDataSource()
        {

         
            DataTable dt = new DataTable();            
            dt.Columns.Add(new DataColumn("WeatherTextField", typeof(String)));
            dt.Columns.Add(new DataColumn("WeatherValueField", typeof(String)));
            dt.Rows.Add(CreateRow(" ", "1", dt));
            dt.Rows.Add(CreateRow(" ", "2", dt));
            dt.Rows.Add(CreateRow(" ", "17", dt));
            dt.Rows.Add(CreateRow(" ", "28", dt));
            dt.Rows.Add(CreateRow(" ", "56", dt));
            dt.Rows.Add(CreateRow(" ", "57", dt));
            dt.Rows.Add(CreateRow(" ", "69", dt));
            dt.Rows.Add(CreateRow(" ", "78", dt));
            dt.Rows.Add(CreateRow(" ", "82", dt));
            dt.Rows.Add(CreateRow(" ", "84", dt));
            dt.Rows.Add(CreateRow("  ", "103", dt));
            dt.Rows.Add(CreateRow("  ", "115", dt));
            dt.Rows.Add(CreateRow("  ", "125", dt));
            dt.Rows.Add(CreateRow("  ", "127", dt));
            dt.Rows.Add(CreateRow("  ", "140", dt));
            dt.Rows.Add(CreateRow("  ", "150", dt));
            dt.Rows.Add(CreateRow("  ", "166", dt));
            dt.Rows.Add(CreateRow("  ", "179", dt));
            dt.Rows.Add(CreateRow("  ", "186", dt));
            dt.Rows.Add(CreateRow("  ", "189", dt));
            dt.Rows.Add(CreateRow("  ", "211", dt));
            dt.Rows.Add(CreateRow("  ", "212", dt));
            dt.Rows.Add(CreateRow("  ", "218", dt));
            dt.Rows.Add(CreateRow("  ", "227", dt));
            dt.Rows.Add(CreateRow("  ", "232", dt));
            dt.Rows.Add(CreateRow("  ", "244", dt));
            dt.Rows.Add(CreateRow("  ", "248", dt));
            dt.Rows.Add(CreateRow("  ", "252", dt));
            dt.Rows.Add(CreateRow("  ", "255", dt));
            dt.Rows.Add(CreateRow("  ", "264", dt));
            dt.Rows.Add(CreateRow("  ", "276", dt));
            dt.Rows.Add(CreateRow("  ", "280", dt));
            dt.Rows.Add(CreateRow("  ", "287", dt));
            dt.Rows.Add(CreateRow("  ", "292", dt));
            dt.Rows.Add(CreateRow("  ", "295", dt));
            dt.Rows.Add(CreateRow("  ", "296", dt));
            dt.Rows.Add(CreateRow("  ", "303", dt));
            DataView dv = new DataView(dt);
            return dv;

        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Text"></param>
        /// <param name="Value"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        DataRow CreateRow(String Text, String Value, DataTable dt)
        {
            DataRow dr = dt.NewRow();
            dr[0] = Text;
            dr[1] = Value;
            return dr;

        }
        public bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
        {
            // , 
            return true;
        }