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");
}
}
作者:ylbtech
出处:http://ylbtech.cnblogs.com/








