示例#1
0
    protected void btnPost_Click(object sender, EventArgs e)
    {
        using (eCommerceDBEntities context = new eCommerceDBEntities())
        {
            if (Session["CustomerID"] != null)
            {
                int CustID = Convert.ToInt16(Session["CustomerID"].ToString());
                int ProdID = Convert.ToInt16(Request.QueryString["ProductID"]);

                Review rv = new Review()
                {
                    ReviewTitle = txtReviewTitle.Text,
                    ReviewDescription = txtReviewDetail.Text,
                    CustomerID = CustID,
                    ProductID = ProdID,
                    Rating = Convert.ToInt16(ddlRatings.SelectedValue),
                    ReviewDate = DateTime.Now
                };

                context.Reviews.AddObject(rv);
                context.SaveChanges();

                string notifyTitle = "Review added";
                string message = "Your review has been posted on the product page. Thanks for helping others.";
                string notification = string.Format("?notifyTitle={0}&notificationDescription={1}", notifyTitle, message);

                Response.Redirect("~/product.aspx?ProductID=" + ViewState["prodid"].ToString() + "&" + notification);
            }
        }
    }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["CustomerID"] == null)
        {
            Response.Redirect("login.aspx");
        }
        else
        {
            if (!IsPostBack)
            {
                using (eCommerceDBEntities context = new eCommerceDBEntities())
                {
                    //Getting user info based on session variable
                    int id = (int)Session["CustomerID"];
                    Customer cust = context.Customers.Where(i => i.CustomerID == id).FirstOrDefault();

                    //Setting page title.
                    Page.Title = "Profile | " + cust.CustomerName;

                    //Setting values from DB
                    txtName.Text = cust.CustomerName;
                    txtUserName.Text = cust.UserName;
                    txtContact.Text = cust.ContactNumber;
                    ddlGender.SelectedValue = cust.sex;
                    txtEmail.Text = cust.email;
                    txtAddress.Text = cust.Address;
                }
            }
        }
    }
示例#3
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        using (eCommerceDBEntities context = new eCommerceDBEntities())
        {
            //Check if there's any user who has the given username and password
            Customer cust = context.Customers.Where(i => i.UserName == txtUserName.Text &&
                i.Password == txtPassword.Text).FirstOrDefault();

            if (cust == null)
            {
                //User not found
                lblError.Text = "Wrong username or password";
                lblError.Visible = true;
            }
            else
            {
                //Create a session for user
                Session["CustomerID"] = cust.CustomerID;

                string notifyTitle = "Welcome!";
                string message = "You have been successfully logged in. Happy shopping!";
                string notification = string.Format("?notifyTitle={0}&notificationDescription={1}", notifyTitle, message);

                //If user is requesting a redirect.
                string redirectToURL =  Request.QueryString["redirect"];
                if(string.IsNullOrEmpty(redirectToURL))
                {
                    Response.Redirect("~/home.aspx" + notification);
                }
                else
                    Response.Redirect(redirectToURL);
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if(Request.QueryString["notifyTitle"] != null || Request.QueryString["notificationDescription"] != null)
        {
            string title = Request.QueryString["notifyTitle"];
            string message = Request.QueryString["notificationDescription"];
            string jsFunction = string.Format("showNotification('{0}','{1}')",title,message);
            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "notify", jsFunction, true);
        }

        using (eCommerceDBEntities context = new eCommerceDBEntities())
        {
            //Check if some user is logged in.
            if (Session["CustomerID"] != null)
            {
                //Getting user info based on session variable
                int id = (int)Session["CustomerID"];
                Customer cust = context.Customers.Where(i => i.CustomerID == id).FirstOrDefault();
                //Change the links
                lnkLogInLogOut.Text = "Logout";
                lnkLogInLogOut.PostBackUrl = "logout.aspx";

                lnkSignUpProfile.Text = "Welcome: " + cust.CustomerName;
                lnkSignUpProfile.PostBackUrl = "~/profile.aspx?CustomerID=" + cust.CustomerID;

                //Update Cart count
                var cart = (from c in context.Carts
                            join p in context.Products
                                on c.ProductID equals p.ProductID
                                where c.CustomerID==id
                            select new { p.ProductName, p.ProductPrice, p.ProductImageURL });
                lblCartCount.Text = cart.Count().ToString();
            }
        }
    }
示例#5
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        try
        {
            //Save the file on server's folder kepping the original filename
            flImageUpload.SaveAs(Server.MapPath(@"~\Site_data\product_images\" + flImageUpload.FileName));

            Product pr = new Product
            {
                ProductName = txtName.Text,
                ProductDescription = txtDescription.Text,
                ProductPrice = Convert.ToDecimal(txtPrice.Text),
                ProductImageURL = @"~\Site_data\product_images\" + flImageUpload.FileName,
                Discount = Convert.ToInt16(string.IsNullOrEmpty(txtDiscount.Text) ? "0" : txtDiscount.Text),
                CategoryID = Convert.ToInt16(ddlCategory.SelectedValue)
            };

            using(eCommerceDBEntities context = new eCommerceDBEntities())
            {
                context.Products.AddObject(pr);
                context.SaveChanges();
            }

            lblStatus.Text = "Product successfully uploaded.";
            lblStatus.ForeColor = System.Drawing.Color.Green;
            hlAddFeature.NavigateUrl = "~/Admin/addFeatures.aspx?ProductID=" + pr.ProductID;
        }
        catch (System.IO.DirectoryNotFoundException ex)
        {
            lblStatus.ForeColor= System.Drawing.Color.Red;
            lblStatus.Text = "Select an image first";
        }
    }
示例#6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //Get the lookup string form URL
            string lookup = Request.QueryString["product"];
            string category = Request.QueryString["category"];

            Page.Title = "Search: " + lookup;

            //Keeping the lookup string in searchbar for ease of use
            ((TextBox)this.Page.Master.FindControl("txtSearch")).Text = lookup;

            using (eCommerceDBEntities context = new eCommerceDBEntities())
            {
                //Running %like query on 2 fields to get best results from DB
                List<Product> pr = context.Products.Where(i => i.ProductName.Contains(lookup) ||
                    i.ProductDescription.Contains(lookup)
                    ).ToList();

                var lq = (from p in context.Products
                          join c in context.Categories
                          on p.CategoryID equals c.CategoryID
                          where (string.IsNullOrEmpty(category) ? true : c.CategoryName == category) &&
                                (string.IsNullOrEmpty(lookup)? true : p.ProductName.Contains(lookup) || p.ProductDescription.Contains(lookup))
                          select p).ToList();

                Repeater1.DataSource = lq;
                Repeater1.DataBind();
            }

        }
    }
示例#7
0
    protected void btnNextBook_Click(object sender, EventArgs e)
    {
        //Enable prev button if it's disabled.
        if (btnPrevBook.Enabled == false)
            btnPrevBook.Enabled = true;
        using (eCommerceDBEntities context = new eCommerceDBEntities())
        {
            List<Product> books = context.Products.Where(p => p.CategoryID == 4).ToList();
            int i = (int)ViewState["rowBooks"];

            //Get the next row
            i++;
            try
            {
                lblBookPrice.Text = books[i].ProductPrice.ToString();
                lnkBookTitle.Text = books[i].ProductName;
                lnkBookTitle.NavigateUrl = "product.aspx?ProductID=" + books[i].ProductID;
                lnkImageLinkToBook.NavigateUrl = lnkBookTitle.NavigateUrl;
                imgProductBook.ImageUrl = books[i].ProductImageURL;
                lnkBookOrder.NavigateUrl = lnkBookTitle.NavigateUrl;
            }
            catch (ArgumentOutOfRangeException ex)
            {
                //There aren't anymore rows so, disable further action.
                btnNextBook.Enabled = false;
                i--;
            }

            //Updating viewstate for next use.
            ViewState["rowBooks"] = i;
        }
    }
    protected void btnPasswordRecover_Click(object sender, EventArgs e)
    {
        using (eCommerceDBEntities context = new eCommerceDBEntities())
        {
            Customer cust = context.Customers.Where(i => i.email==txtEmail.Text).FirstOrDefault();
            if (cust == null)
            {
                string title = "User ID not found";
                string message = "No user found with the given email ID. Please provide the email ID you signed up with.";
                string jsFunction = string.Format("showNotification('{0}','{1}')", title, message);
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "notify", jsFunction, true);
            }
            else
            {
                string email = cust.email;
                string password = cust.Password;
                MailMessage mail = new MailMessage("*****@*****.**", email);
                mail.Subject = "Password for your eCommerce ID";
                mail.Body = "Your password for eCommerce is : " + password;
                mail.IsBodyHtml = false;

                SmtpClient smp = new SmtpClient();
                //smp.Send(mail);

                string title = "Password sent!";
                string message = "Your password has been sent to " + email;
                string jsFunction = string.Format("showNotification('{0}','{1}')", title, message);
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "notify", jsFunction, true);
            }
        }
    }
示例#9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         using(eCommerceDBEntities context = new eCommerceDBEntities())
         {
             List<Category> ct = context.Categories.ToList();
             ddlCategory.DataSource = ct ;
             ddlCategory.DataTextField = "CategoryName";
             ddlCategory.DataValueField = "CategoryID";
             ddlCategory.DataBind();
         }
     }
 }
    protected void btnChange_Click(object sender, EventArgs e)
    {
        using (eCommerceDBEntities context = new eCommerceDBEntities())
        {
            //Getting user info based on session variable
            int id = (int)Session["CustomerID"];
            Customer cust = context.Customers.Where(i => i.CustomerID == id).FirstOrDefault();

            cust.Password = txtPassword.Text;
            context.SaveChanges();
        }
        lblError.Visible = true;
        lblError.Text = "Password successfully updated";
    }
示例#11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int id = Convert.ToInt16(Request.QueryString["ProductID"]);
            ViewState["prodid"] = id;
            using (eCommerceDBEntities context = new eCommerceDBEntities())
            {
                if (Session["CustomerID"] == null)
                {
                    Panel1.Enabled = false;
                }
                Product pr = context.Products.Where(i => i.ProductID == id).FirstOrDefault();
                lblName.Text = pr.ProductName;
                lblPrice.Text += pr.ProductPrice.ToString();
                lblDescription.Text = pr.ProductDescription;
                imgProductImage.ImageUrl = pr.ProductImageURL;

                //Setting page title
                Page.Title = pr.ProductName;

                //Joing feature tables to show data on datagrid
                var lq = (from f in context.Features
                          join mf in context.MetaFeatures
                              on f.MetaFeatureID equals mf.MetaFeatureID
                          where f.ProductID == id
                          select new { Feature = mf.FeatureName, Description = f.FeatureDescription }).ToList();

                GridView1.DataSource = lq;
                GridView1.DataBind();

                //Populating reviews
                var review = (from r in context.Reviews
                              where r.ProductID == id
                              join c in context.Customers
                                  on r.CustomerID equals c.CustomerID
                              select new {
                                r.ReviewDate,
                                r.ReviewTitle,
                                r.ReviewDescription,
                                r.Rating,
                                c.CustomerName
                              });
                Repeater1.DataSource = review;
                Repeater1.DataBind();

            }
        }
    }
示例#12
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        using (eCommerceDBEntities context = new eCommerceDBEntities())
        {
            Customer cust = context.Customers.Where(i => i.UserName==txtUserName.Text).FirstOrDefault();

            cust.CustomerName = txtName.Text;
            cust.email = txtEmail.Text;
            cust.ContactNumber = txtContact.Text;
            cust.Address = txtAddress.Text;
            cust.Password = txtPassword.Text;
            cust.sex = ddlGender.SelectedValue;
            cust.UserType = ddlUserType.SelectedValue;

            context.SaveChanges();
        }
    }
示例#13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            txtProductID.Text =  Request.QueryString["ProductID"];

            //Fill the list from table
            using (eCommerceDBEntities context = new eCommerceDBEntities())
            {
                List<MetaFeature> mf = context.MetaFeatures.ToList();
                ddlFeatureName.DataSource = mf;
                ddlFeatureName.DataTextField = "FeatureName";
                ddlFeatureName.DataValueField = "MetaFeatureID";
                ddlFeatureName.DataBind();
            }
        }
    }
示例#14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        using (eCommerceDBEntities context = new eCommerceDBEntities())
        {
            var lq = (from o in context.Orders
                      join p in context.Products
                      on o.ProductID equals p.ProductID
                      select new {
                          o.OrderID,
                          o.DateOrdered,
                          p.ProductName,
                          p.ProductPrice,
                          p.Discount,
                      });

            GridView1.DataSource = lq;
            GridView1.DataBind();
        }
    }
示例#15
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        using (eCommerceDBEntities context = new eCommerceDBEntities())
        {
            //Getting user info based on session variable
            int id = (int)Session["CustomerID"];
            Customer cust = context.Customers.Where(i => i.CustomerID == id).FirstOrDefault();

            cust.CustomerName = txtName.Text;
            cust.sex = ddlGender.SelectedValue;
            cust.UserName = txtUserName.Text;
            cust.Address = txtAddress.Text;
            cust.email = txtEmail.Text;
            cust.ContactNumber = txtContact.Text;

            context.SaveChanges();
        }
        lblError.Visible = true;
        lblError.Text = "Details successfully updated";
    }
示例#16
0
    protected void btnPay_Click(object sender, EventArgs e)
    {
        using (eCommerceDBEntities context = new eCommerceDBEntities())
        {
            int custID = Convert.ToInt16(Session["CustomerID"]);
            if (string.IsNullOrEmpty(txtAmount.Text))
            {
                lblStatus.Text = "Please select mode of payment Debit/Credit card";
                lblStatus.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                List<Cart> cart = context.Carts.Where(i => i.CustomerID == custID).ToList();

                foreach (var i in cart)
                {
                    //Fill order table
                    context.Orders.AddObject(new Order
                    {
                        CustomerID = custID,
                        ProductID = i.ProductID,
                        DateOrdered = DateTime.Now
                    });

                    //Product is bought so, empty the cart.
                    context.Carts.DeleteObject(i);
                }
                context.SaveChanges();

                lblStatus.Text = "Your order has been placed. Happy shopping!";
                lblStatus.ForeColor = System.Drawing.Color.Green;

                string notifyTitle = "Payment Successful!";
                string message = "The order has been placed. You will receive your shipment sonn.";
                string notification = string.Format("?notifyTitle={0}&notificationDescription={1}", notifyTitle, message);

                Response.Redirect("~/order.aspx" + notification);
            }
        }
    }
示例#17
0
    protected void btnSignup_Click(object sender, EventArgs e)
    {
        using (eCommerceDBEntities context = new eCommerceDBEntities())
        {
            //New user object created from the information in the webform.
            Customer newUser = new Customer()
            {
                CustomerName = txtName.Text,
                sex = ddlGender.SelectedValue,
                UserName = txtUserName.Text,
                Password = txtPassword.Text,
                Address = txtAddress.Text,
                email = txtEmail.Text,
                ContactNumber = txtContact.Text,
                UserType = "customer"
            };

            //Lookup if a user with the given username or email already exists in DB.
            Customer cust = context.Customers.Where(i => i.UserName == newUser.UserName
               || i.email == newUser.email).FirstOrDefault();

            //If user is found, show error, else add new user.
            if (cust != null)
            {
                lblError.Text = "A user with that Email ID or UserName already exists.";
                lblError.Visible = true;
            }
            else
            {
                //Add new user to the customers' context
                context.Customers.AddObject(newUser);
                //Save new user in the database.
                context.SaveChanges();

                //Send user to loginpage
                Response.Redirect("login.aspx");
            }

        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        using (eCommerceDBEntities context = new eCommerceDBEntities())
        {
            if (Session["CustomerID"] != null)
            {
                //Getting user info based on session variable
                int id = (int)Session["CustomerID"];
                Customer cust = context.Customers.Where(i => i.CustomerID == id).FirstOrDefault();

                if (cust.UserType != "admin")
                {
                    Response.Redirect("~/home.aspx");
                }
            }
            else
            {
                Response.Redirect("~/home.aspx");
            }

        }
    }
示例#19
0
    protected void lnkRemoveItem_Click(object sender, EventArgs e)
    {
        using (eCommerceDBEntities context = new eCommerceDBEntities())
        {
            //Get the reference of the clicked button.
            LinkButton button = (sender as LinkButton);
            //Get the Repeater Item reference
            RepeaterItem item = button.NamingContainer as RepeaterItem;
            //Get the repeater item index
            int index = item.ItemIndex;
            string id = ((Label)(Repeater1.Items[index].FindControl("lblHiddenCartID"))).Text;
            int cartid = Convert.ToInt16(id);
            Cart cr = context.Carts.Where(i => i.CartID == cartid).FirstOrDefault();

            context.Carts.DeleteObject(cr);
            context.SaveChanges();

            string notifyTitle = "One item removed";
            string message = "One item was removed from your cart!";
            string notification = string.Format("?notifyTitle={0}&notificationDescription={1}", notifyTitle, message);

            Response.Redirect("~/order.aspx" + notification);
        }
    }
示例#20
0
    protected void btnLoad_Click(object sender, EventArgs e)
    {
        using (eCommerceDBEntities context = new eCommerceDBEntities())
        {
            Customer cust = context.Customers.Where(i => i.UserName.Contains(txtUserName.Text)).FirstOrDefault();

            txtName.Enabled = true;
            txtEmail.Enabled = true;
            txtContact.Enabled = true;
            txtAddress.Enabled = true;
            ddlGender.Enabled = true;
            txtPassword.Enabled = true;
            ddlUserType.Enabled = true;

            txtUserName.Text = cust.UserName;
            txtName.Text = cust.CustomerName;
            txtEmail.Text = cust.email;
            txtContact.Text = cust.ContactNumber;
            txtAddress.Text = cust.Address;
            txtPassword.Text = cust.Password;
            ddlGender.SelectedValue = cust.sex;
            ddlUserType.SelectedValue = cust.UserType;
        }
    }
示例#21
0
 private void addAmount()
 {
     int CustomerID = Convert.ToInt16(Session["CustomerID"].ToString());
     using (eCommerceDBEntities context = new eCommerceDBEntities())
     {
         var cart = (from c in context.Carts
                     join p in context.Products
                         on c.ProductID equals p.ProductID
                         where c.CustomerID == CustomerID
                     select new { p.ProductPrice, c.Quantity });
         decimal amt = 0;
         foreach (var i in cart)
         {
             amt += (i.ProductPrice * i.Quantity);
         }
         txtAmount.Text = amt.ToString();
     }
 }
示例#22
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        using (eCommerceDBEntities context = new eCommerceDBEntities())
        {
            if (rdoChooseFeature.SelectedValue == "1")
            {
                Feature fr = new Feature()
                {
                    MetaFeatureID = Convert.ToInt16(ddlFeatureName.SelectedValue),
                    ProductID = Convert.ToInt16(txtProductID.Text),
                    FeatureDescription = txtBoxFeatureValue.Text
                };
                context.Features.AddObject(fr);
            }
            else if (rdoChooseFeature.SelectedValue == "2")
            {
                //Show error on empty textbox
                if (string.IsNullOrEmpty(txtFeatureName.Text))
                {
                    lblStatus.ForeColor = System.Drawing.Color.Red;
                    lblStatus.Text = "Please add a feature name.";
                }
                else
                {
                    //Check if the feature already exists
                    MetaFeature mr = context.MetaFeatures.Where(i => i.FeatureName == txtFeatureName.Text).FirstOrDefault();
                    int id;
                    //If not found, create new row
                    if (mr == null)
                    {
                        MetaFeature mfr = new MetaFeature()
                        {
                            FeatureName = txtFeatureName.Text
                        };

                        context.MetaFeatures.AddObject(mfr);
                        context.SaveChanges();
                        //get the ID which is just created
                        id = mfr.MetaFeatureID;

                        Feature fr = new Feature()
                        {
                            MetaFeatureID = id,
                            ProductID = Convert.ToInt16(txtProductID.Text),
                            FeatureDescription = txtBoxFeatureValue.Text
                        };
                        context.Features.AddObject(fr);
                    }
                    //if found, update row.
                    else
                    {
                        id = mr.MetaFeatureID;
                        Feature fUpdate = context.Features.Where(i => i.MetaFeatureID == id).FirstOrDefault();
                        fUpdate.FeatureDescription = txtBoxFeatureValue.Text;
                     }
                }
            }
            context.SaveChanges();
            lblStatus.ForeColor = System.Drawing.Color.Green;
            lblStatus.Text = "Feature added successfully. You can add more!";
        }
    }
示例#23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["CustomerID"] == null)
        {
            string redirectToURL = "~/order.aspx";
            Response.Redirect("~/login.aspx?redirect=" + redirectToURL);
        }

        if (!IsPostBack)
        {
            //Get logged in id
            int CustID = Convert.ToInt16(Session["CustomerID"]);
            using (eCommerceDBEntities context = new eCommerceDBEntities())
            {
                if (Request.QueryString["addToCart"] != null)
                {
                    int ProdID = Convert.ToInt16(Request.QueryString["addToCart"]);

                    //Check if product is already in cart
                    Cart cr = context.Carts.Where(i => i.ProductID == ProdID).FirstOrDefault();
                    //If not in the DB add it.
                    if (cr == null)
                    {
                        context.Carts.AddObject(new Cart
                        {
                            CustomerID = CustID,
                            ProductID = ProdID,
                            Quantity = 1
                        });
                        context.SaveChanges();
                    }
                }

                var cart = (from c in context.Carts
                            join p in context.Products
                                on c.ProductID equals p.ProductID
                            where c.CustomerID == CustID
                            select new { p.ProductName, p.ProductPrice, p.ProductImageURL, c.CartID });
                Repeater1.DataSource = cart;
                Repeater1.DataBind();

                Boolean isCartEmpty = context.Carts.Where(i=>i.CustomerID == CustID).FirstOrDefault() == null;
                //If cart is empty. No ID label means, no cart item
                if (isCartEmpty)
                {
                    Wizard1.Visible = false;
                    lblMessage.Visible = true;
                }
            }
        }
    }
示例#24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //Populating Mobile category
            //Instantiating the entity class to access DB tables
            using (eCommerceDBEntities context = new eCommerceDBEntities())
            {
                //Query the DB for products which are mobile i.e. CategoryID == 1
                List<Product> pr = context.Products.Where(i => i.CategoryID == 1).ToList();

                //At first launch, fill fields with first rowMobile i.e. pr[0]
                lblPrice.Text = pr[0].ProductPrice.ToString();
                lnkProductTitle.Text = pr[0].ProductName;
                lnkProductTitle.NavigateUrl = "product.aspx?ProductID=" + pr[0].ProductID;
                lnkImageLinkTo.NavigateUrl = lnkProductTitle.NavigateUrl;
                imgProduct.ImageUrl = pr[0].ProductImageURL;
                lnkOrder.NavigateUrl = lnkProductTitle.NavigateUrl;

                //Store returned rowMobile in viewstate for it to persist, to be used later.
                ViewState["rowMobile"] = 0;

                //Populating Books category
                //Query the DB for products which are books i.e. CategoryID == 4
                List<Product> books = context.Products.Where(i => i.CategoryID == 4).ToList();
                //At first launch, fill fields with first row i.e. pr[0]
                lblBookPrice.Text = books[0].ProductPrice.ToString();
                lnkBookTitle.Text = books[0].ProductName;
                lnkBookTitle.NavigateUrl = "product.aspx?ProductID=" + books[0].ProductID;
                lnkImageLinkToBook.NavigateUrl = lnkBookTitle.NavigateUrl;
                imgProductBook.ImageUrl = books[0].ProductImageURL;
                lnkBookOrder.NavigateUrl = lnkBookTitle.NavigateUrl;

                //Store returned rowBook in viewstate for it to persist, to be used later.
                ViewState["rowBooks"] = 0;

                //Populating Clothes category
                //Query the DB for products which are clothes i.e. CategoryID == 3
                List<Product> clothes = context.Products.Where(i => i.CategoryID == 3).ToList();
                //At first launch, fill fields with first row i.e. pr[0]
                lblClothesPrice.Text = clothes[0].ProductPrice.ToString();
                lnkClothesTitle.Text = clothes[0].ProductName;
                lnkClothesTitle.NavigateUrl = "product.aspx?ProductID=" + clothes[0].ProductID;
                lnkImageLinkToClothes.NavigateUrl = lnkClothesTitle.NavigateUrl;
                imgProductClothes.ImageUrl = clothes[0].ProductImageURL;
                lnkClothesOrder.NavigateUrl = lnkClothesTitle.NavigateUrl;

                //Store returned rowBook in viewstate for it to persist, to be used later.
                ViewState["rowClothes"] = 0;
            }

        }
    }