Пример #1
0
        private void loadSearch()
        {
            string location = Session["searchWalk"].ToString();

            string sqlQuery = @"SELECT Walk.WalkID, Walk.WalkName, Location.Location, Walk.WalkAddress, Walk.WalkPostcode," +
                              " Walk.Description FROM Walk JOIN Location ON Location.LocationID = Walk.LocationID" +
                              " JOIN Users ON Walk.UserID = Users.UserID WHERE Location.Location LIKE '%" + location + "%' OR" +
                              " Walk.Postcode LIKE '%" + location + "%' OR Walk.WalkName LIKE '%" + location + "%' AND Walk.Published = 'True'";


            ConnectionClass conn = new ConnectionClass();

            conn.retrieveData(sqlQuery);

            DataTable dt = new DataTable();

            dt.Columns.AddRange(new DataColumn[]
            {
                new DataColumn("WalkID", typeof(int)),
                new DataColumn("WalkName", typeof(string)),
                new DataColumn("Location", typeof(string)),
                new DataColumn("WalkAddress", typeof(string)),
                new DataColumn("WalkPostcode", typeof(string)),
                new DataColumn("Description", typeof(string))
            });

            foreach (DataRow dr in conn.SQLTable.Rows)
            {
                int    WalkID       = (int)dr[0];
                string WalkName     = (string)dr[1];
                string Location     = (string)dr[2];
                string WalkAddress  = (string)dr[3];
                string WalkPostcode = (string)dr[4];
                string Description  = (string)dr[5];

                dt.Rows.Add(WalkID, WalkName, Location, WalkAddress, WalkPostcode, Description);
            }

            this.grdWalks.DataSource = dt;
            this.grdWalks.DataBind();
        }
Пример #2
0
        protected void lstMyWalks_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = lstMyWalks.SelectedDataKey.Value.ToString();

            string          sqlQuery = @"SELECT WalkID FROM Walk WHERE WalkPostcode = '" + value + "'";
            ConnectionClass conn     = new ConnectionClass();

            conn.retrieveData(sqlQuery);

            string WalkID = "";

            foreach (DataRow dr in conn.SQLTable.Rows)
            {
                WalkID = (string)dr[0];
            }

            Session["WalkID"]   = WalkID;
            Session["userWalk"] = "userWalk";

            Response.Redirect("../User_WalkPreview.aspx");
        }