コード例 #1
0
        protected void submitsearch_Click(object sender, EventArgs e)
        {
            //remove unwanted chars
            Utility util  = new Utility();
            string  srch1 = util.CleanInput(search1.Text);
            string  srch2 = util.CleanInput(search2.Text);

            //search twitter
            MyTwitterObj MyTwitter = new MyTwitterObj();

            MyTwitter.search_1 = srch1;
            MyTwitter.search_2 = srch2;
            Twitter twitter = new Twitter();

            MyTwitter = twitter.GetData(MyTwitter);

            //store in DB
            DBInteractions DBI = new DBInteractions();

            DBI.StoreInDB(search1.Text, MyTwitter.tweets_1, search2.Text, MyTwitter.tweets_2, MyTwitter.seconds_1, MyTwitter.seconds_2);

            //go to next page
            HttpContext CurrContext = HttpContext.Current;

            CurrContext.Items.Add("srch1", search1.Text);
            CurrContext.Items.Add("srch2", search2.Text);
            CurrContext.Items.Add("tweets1", MyTwitter.tweets_1);
            CurrContext.Items.Add("tweets2", MyTwitter.tweets_2);
            CurrContext.Items.Add("seconds1", MyTwitter.seconds_1);
            CurrContext.Items.Add("seconds2", MyTwitter.seconds_2);
            Server.Transfer("Results.aspx");
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                //Populating a DataTable from database.
                DBInteractions DBI = new DBInteractions();
                DataTable      dt  = DBI.GetData();

                //Building an HTML string.
                StringBuilder html = new StringBuilder();

                //Table start.
                html.Append("<table border = '1'>");

                //Building the Header row.
                html.Append("<tr>");
                foreach (DataColumn column in dt.Columns)
                {
                    html.Append("<th>");
                    html.Append(column.ColumnName);
                    html.Append("</th>");
                }
                html.Append("</tr>");

                //Building the Data rows.
                foreach (DataRow row in dt.Rows)
                {
                    html.Append("<tr>");
                    foreach (DataColumn column in dt.Columns)
                    {
                        html.Append("<td>");
                        html.Append(row[column.ColumnName]);
                        html.Append("</td>");
                    }
                    html.Append("</tr>");
                }

                //Table end.
                html.Append("</table>");

                //Append the HTML string to Placeholder.
                PlaceHolder1.Controls.Add(new Literal {
                    Text = html.ToString()
                });
            }
        }