protected void Page_Load(object sender, EventArgs e)
 {
     _webpageId = AbleCommerce.Code.PageHelper.GetWebpageId();
     if (!Page.IsPostBack)
     {
         ProductPageList.DataBind();
         ListItem item = ProductPageList.Items.FindByValue(_webpageId.ToString());
         if (item != null)
         {
             item.Selected = true;
         }
         ProductsGrid.DataBind();
     }
 }
        protected void Page_Init(object sender, EventArgs e)
        {
            if (Session["AId"] == null)
            {
                Response.Redirect("~/default.aspx");
            }

            pro_id = Request.QueryString.Get("pid").ToString();
            if (pro_id == String.Empty)
            {
                Response.Redirect("products.aspx");
            }

            SqlDataSource SqlDataSource1 = new SqlDataSource();

            SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            SqlDataSource1.SelectCommand = @"SELECT [product_id], [product_name], [product_desc], [product_price], [product_stock], [product_cdate], [product_image1], [product_image2], [product_image3], [category_id] FROM [Product] WHERE [product_id] = @product_id";

            SqlDataSource1.SelectParameters.Add("product_id", pro_id);

            DataSourceSelectArguments args = new DataSourceSelectArguments();
            DataView dv     = SqlDataSource1.Select(args) as DataView;
            string   cat_id = dv.Table.Rows[0][9].ToString();

            txtProductName.Text  = dv.Table.Rows[0][1].ToString();
            txtProductDesc.Text  = dv.Table.Rows[0][2].ToString();
            txtProductPrice.Text = dv.Table.Rows[0][3].ToString();
            txtProductQty.Text   = dv.Table.Rows[0][4].ToString();

            dv.Dispose();

            SqlDataSource1.SelectCommand = @"SELECT [category_id],[category_name] FROM Category";

            //SqlDataSource1.SelectParameters.Add("cat_id", cat_id);

            ProductPageList.DataSource     = SqlDataSource1;
            ProductPageList.DataTextField  = "category_name";
            ProductPageList.DataValueField = "category_id";
            ProductPageList.SelectedIndex  = Convert.ToInt32(cat_id) - 1;
            ProductPageList.DataBind();


            SqlDataSource1.Dispose();
        }