public partial class Create : System.Web.UI.Page
{
/// <summary>
/// 1,类别列表
/// </summary>
private void Bind()
{
dropCategory.DataSource = CategoryOper.GetAll();
dropCategory.DataTextField = "categoryName";
dropCategory.DataValueField = "categoryId";
dropCategory.DataBind();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Bind();
}
}
protected void btnAdd_Click(object sender, EventArgs e)
{
ProductInfo dal = new ProductInfo() {
ProductName=txtProductName.Text.Trim(),
Unitprice=Convert.ToDecimal(txtUnitprice.Text.Trim()),
Special=rblSpecial.SelectedValue,
CategoryId=Convert.ToInt32(dropCategory.SelectedValue)
};
//调用添加方法
ProductOper.Add(dal);
Response.Redirect("~/Default.aspx");
}
}