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