0

I'm trying to make an "online store" and I need an admin page that can add a product and have it show on the dropdown list.

I've tried a server transfer but can't seem to find the right code to make it happen.

index.aspx.cs

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            using (ShopContext context = new ShopContext())
            {
                Purchase purchase = new Purchase();
                purchase.FirstName = txtFirstName.Text;
                purchase.LastName = txtLastName.Text; ;
                purchase.Email = txtEmail.Text;
                purchase.Newsletter = chkNewsletter.Checked;
                purchase.Album = drpAlbum.SelectedValue;

                context.Purchases.Add(purchase);
                context.SaveChanges();
                //Response.Redirect("view-purchases.aspx");
            }
            pnlForm.Visible = false;
            pnlConfirm.Visible = true;
            lblFirstName.Text = txtFirstName.Text;
            lblLastName.Text = txtLastName.Text;
            lblEmail.Text = txtEmail.Text;

            if (chkNewsletter.Checked)
            {
                lblNewsletter.Text = "Registered";
            }
            else
            {
                lblNewsletter.Text = "Not Registered";
            }

            lblAlbum.Text = drpAlbum.SelectedValue;

        }
    }
}

adminpage.aspx.cs

    public partial class adminpage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnAddAlbum_Click(object sender, EventArgs e)
    {
        Page.Server.Transfer("index.aspx");
    }
}

I expect the dropdown list from index.aspx to update when a new album is added on the adminpage.aspx page

  • 1
    See [How to pass values from one page to another](https://stackoverflow.com/q/14956027/242) – Dhaust Jun 06 '19 at 22:25
  • 1
    Possible duplicate of [How to pass values across the pages in ASP.net without using Session](https://stackoverflow.com/questions/14956027/how-to-pass-values-across-the-pages-in-asp-net-without-using-session) – dpant Jun 07 '19 at 10:34

0 Answers0