protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var id = string.IsNullOrEmpty(Request.QueryString["id"]) ? 0 : Convert.ToInt32(Request.QueryString["id"]); if (id == 0) { Response.Redirect("~/Default.aspx"); } var dataAccess = new HeroicData(); var user = dataAccess.ExecuteTable <User>( query: "SELECT * FROM [User] WHERE ID = @id", parameters: new List <HeroicData.Parameters> { new HeroicData.Parameters { Name = "@id", Value = id } }).FirstOrDefault(); if (user == null) { Response.Redirect("~/Default.aspx"); } hidID.Value = user.ID.ToString(); txtUserName.Text = user.UserName; txtPassword.Text = user.Password; txtEmail.Text = user.Email; txtMobile.Text = user.Mobile; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var heroicData = new HeroicData(); //var dataAccess = new DataAccess(connectionString: "YOUR_CONNECTION_STRING"); //this.lv.DataSource = dataAccess.ExecuteTable<User>("SELECT * FROM [User]"); //this.lv.DataBind(); var users = heroicData.ExecuteTable("SELECT * FROM [User]"); var count = heroicData.ExecuteScalar("SELECT COUNT(*) FROM [User]"); litCount.Text = $"Showing {count} entries"; this.lv.DataSource = users; this.lv.DataBind(); } }