Esempio n. 1
0
 protected void UL_myEvent(Hashtable h)
 {
     if (DL.Visible)
     {
         DL.DataBind();
     }
 }
Esempio n. 2
0
        protected void BtnSenden_Click(object sender, EventArgs e)
        {
            int id;
            int ok = 0;

            Int32.TryParse(userID, out id);
            if (TxtNew.Text == String.Empty)
            {
                LblAlert.Text = "Bitte gib 'nen Text ein...";
            }
            else
            {
                string     text      = TxtNew.Text;
                string     statement = $"INSERT INTO [Post] ([Text], [Date], [User]) VALUES (@text, @date, @user)";
                SqlCommand cmd       = new SqlCommand(statement, con);
                cmd.Parameters.AddWithValue("@user", id);
                cmd.Parameters.AddWithValue("@date", DateTime.Now);
                cmd.Parameters.AddWithValue("@text", text);
                try
                {
                    con.Open();
                    ok = cmd.ExecuteNonQuery();
                    con.Close();
                }
                catch (Exception)
                {
                    LblAlert.Text = "Klappt nicht";
                }

                if (ok > 0)
                {
                    Response.Redirect("posts.aspx");
                    DL.DataBind();
                }
                else
                {
                    LblAlert.Text = "Senden fehlgeschlagen";
                }
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand("select * from TblRoom", con);
                con.Open();
                MySqlDataAdapter da = new MySqlDataAdapter(cmd);
                DataTable        dt = new DataTable();
                da.Fill(dt);

                DL.DataSource = dt;
                DL.DataBind();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }



            if (Session["user"] == null)
            {
                Session.Remove("user");
                lblUser.Text = "";
            }
            else
            {
                MySqlDataAdapter da  = new MySqlDataAdapter("select * from TblRegistration where Email = '" + Session["user"] + "'", con);
                DataTable        dt1 = new DataTable();
                da.Fill(dt1);
                lblUser.Text = "Hii " + dt1.Rows[0]["FirstName"].ToString();
            }
        }