//点击修改按钮后把数据加载到文本框中便于修改 protected void GV_Style_RowUpdating(object sender, GridViewUpdateEventArgs e) { BLL.T_Style StyleBll = new BLL.T_Style(); if (StyleBll.Select(Convert.ToInt32(GV_Style.Rows[e.RowIndex].Cells[0].Text)).Tables[0].Rows.Count > 0) { //获取数据Id并放在一个控件中 S_Id.Value = StyleBll.Select(Convert.ToInt32(GV_Style.Rows[e.RowIndex].Cells[0].Text)).Tables[0].Rows[0][0].ToString(); TB_Style.Text = StyleBll.Select(Convert.ToInt32(GV_Style.Rows[e.RowIndex].Cells[0].Text)).Tables[0].Rows[0][1].ToString(); //SingerSex.SelectedValue = SingerBll.Select(Convert.ToInt32(GVSinger.Rows[e.RowIndex].Cells[0].Text)).Tables[0].Rows[0][2].ToString(); Add.Visible = false; Update.Visible = true; } else { Response.Write("没有数据"); } }
//删除数据 protected void GV_Style_RowDeleting(object sender, GridViewDeleteEventArgs e) { Model.T_Style Style = new Model.T_Style(); BLL.T_Style SingerBll = new BLL.T_Style(); //Singer.Id = Convert.ToInt32(GVSinger.Rows[e.RowIndex].Cells[0].Text); Style.Id = Convert.ToInt32(SingerBll.Select(Convert.ToInt32(GV_Style.Rows[e.RowIndex].Cells[0].Text)).Tables[0].Rows[0][0].ToString()); if (SingerBll.Delete(Style)) { Response.Write("删除成功"); BindDate(); } else { Response.Write("删除失败"); } }