protected void Page_Load(object sender, EventArgs e) { AuthenticateUser(); intProfile = Int32.Parse(Request.Cookies["profileid"].Value); oDidYouKnow = new DidYouKnow(intProfile, dsn); DataSet ds = oDidYouKnow.Gets(); if (ds.Tables[0].Rows.Count == 0) { strKnow = "<p><div align=\"center\"><br/><img src=\"/images/alert.gif\" border=\"0\" align=\"absmiddle\"/> "Did You Know" has not been configured.</div></p>"; lblTip.Text = "Tip # 0 / 0"; } else { if (Request.QueryString["id"] != null && Request.QueryString["id"] != "") { int intId = Int32.Parse(Request.QueryString["id"]); lblTip.Text = "Tip # " + intId.ToString() + " / " + ds.Tables[0].Rows.Count; intId = intId - 1; strKnow = ds.Tables[0].Rows[intId]["description"].ToString(); } else { Random oRandom = new Random(DateTime.Now.Millisecond); int intId = oRandom.Next(1, ds.Tables[0].Rows.Count); Response.Redirect(Request.Path + "?id=" + intId.ToString()); } } }
protected void btnNext_Click(Object Sender, EventArgs e) { DataSet ds = oDidYouKnow.Gets(); int intId = Int32.Parse(Request.QueryString["id"]); if (intId == ds.Tables[0].Rows.Count) { intId = 1; } else { intId = intId + 1; } Response.Redirect(Request.Path + "?id=" + intId.ToString()); }
private void LoopRepeater() { DataSet ds = oDidYouKnow.Gets(); DataView dv = ds.Tables[0].DefaultView; if (Request.QueryString["sort"] != null) { dv.Sort = Request.QueryString["sort"].ToString(); } rptView.DataSource = dv; rptView.DataBind(); foreach (RepeaterItem ri in rptView.Items) { ImageButton oDelete = (ImageButton)ri.FindControl("btnDelete"); oDelete.Attributes.Add("onClick", "return confirm('Are you sure you want to delete this item?');"); } }