asp.net中gridview的查询、分页、编辑更新、删除的实例代码

2019-05-20 11:18:45王振洲

        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/