protected void Page_Load(object sender, EventArgs e) { string conn = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString; p = new Posting(conn); int pcount = p.CountPosts(); posts = p.GetPosts(); Repeater1.DataSource = posts; Repeater1.DataBind(); lblPCount.Text = pcount.ToString(); }
protected void btnPost_Click(object sender, EventArgs e) { string conn = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString; Posting p = new Posting(conn); try { p.NewPost(txtTitle.Text, txtPost.Text); msg = "Message posted."; txtPost.Text = ""; txtTitle.Text = ""; } catch(Exception ex) { throw new Exception("Error", ex); } Label1.Text = msg; }