asp.net中gridview的查询、分页、编辑更新、删除的(7)

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");
    }
}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjgpxz.html