本文整理汇总了C#中Products.getProductByID方法的典型用法代码示例。如果您正苦于以下问题:C# Products.getProductByID方法的具体用法?C# Products.getProductByID怎么用?C# Products.getProductByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products
的用法示例。
在下文中一共展示了Products.getProductByID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (Request.QueryString.Get("id") != null)
{
int idProduct = Convert.ToInt16(Request.QueryString.Get("id"));
Products product = new Products();
DataTable dt;
dt = product.getProductByID(idProduct);
if (dt != null && dt.Columns[0].Caption == "Product_Not_Exists")
{
Response.Redirect(webURL + "views/products/viewallproducts.aspx?action=notify&id=3", false);
}
else if (dt.Rows.Count == 1)
{
this.productid = dt.Rows[0].ItemArray[0].ToString();
this.name = dt.Rows[0].ItemArray[1].ToString();
DetailsView1.DataSource = dt;
DetailsView1.DataBind();
}
else
{
Response.Redirect(webURL + "views/products/viewallproducts.aspx?action=notify&id=3", false);
}
}
else
{
Response.Redirect(webURL + "views/products/viewallproducts.aspx");
}
}
catch (Exception ex)
{
Response.Redirect(webURL + "views/products/viewallproducts.aspx?action=notify&id=2");
}
}
示例2: loadForm
/// <summary>
/// Method to loads the form with the data of the selected Product
/// </summary>
/// <param name="idCustomer">Int ID of the Product</param>
protected void loadForm(int idProduct)
{
Products product = new Products();
product.idProduct = idProduct;
product.getProductByID();
if (product.idProduct != 0)
{
HiddenField1.Value = product.idProduct.ToString();
TextBox1.Text = product.Name;
TextBox2.Text = product.Amount.ToString();
TextBox3.Text = product.Price.ToString() ;
TextBox4.Text = product.Description;
DropDownList1.SelectedValue = product.idPresentation.ToString();
TextBox5.Text = product.ExpirationDate.ToString("dd/MM/yyyy");
}
else
{
Response.Redirect(webURL + "views/products/viewallproducts.aspx?action=notify&id=3", false);
}
}