//GVSinger分页 protected void GVSinger_PageIndexChanging(object sender, GridViewPageEventArgs e) { BLL.T_Singer SingerBll = new BLL.T_Singer(); this.GVSinger.PageIndex = e.NewPageIndex; this.GVSinger.DataSource = SingerBll.select();//调用绑定的具体方法 this.GVSinger.DataBind(); }
protected void Update_Click(object sender, EventArgs e) { Model.T_Singer Singer = new Model.T_Singer(); Singer.Id = Convert.ToInt32(S_Id.Value); Singer.Name = SingerName.Text.Trim(); Singer.Sex = SingerSex.SelectedItem.ToString(); //Singer.ClassNO = ddlClass.SelectedValue.ToString(); BLL.T_Singer SingerBll = new BLL.T_Singer(); if (SingerBll.Update(Singer)) { Response.Write("DONE"); Add.Visible = true; Update.Visible = false; BindDate(); } else { Response.Write("FAILURE"); } }
//自定义函数,绑定GVSinger数据 private void BindDate() { BLL.T_Singer SingerBll = new BLL.T_Singer(); if (SingerBll.select().Tables[0].Rows.Count > 0) { this.GVSinger.DataSource = SingerBll.select(); this.GVSinger.DataBind(); } else { Response.Write("No Date"); } }
//添加按钮,增加数据 protected void Add_Click(object sender, EventArgs e) { Model.T_Singer singer = new Model.T_Singer(); singer.Name = SingerName.Text.Trim(); singer.Sex = SingerSex.SelectedItem.ToString(); BLL.T_Singer SingerBll = new BLL.T_Singer(); if (SingerBll.Add(singer)) { Response.Write("保存成功"); BindDate(); } else { Response.Write("保存失败"); } }