public void bind() { Bll.PressTable bpre = new Bll.PressTable(); GridView1.DataSource = bpre.select(""); this.GridView1.DataKeyNames = new string[] { "ID" }; this.GridView1.DataBind(); }
protected void Button2_Click(object sender, EventArgs e) { if (TextBox3.Text != "") { if (DropDownList1.Text == "出版社名字") { Bll.PressTable bpre = new Bll.PressTable(); this.GridView1.DataSource = bpre.select("PreName like '%" + TextBox3.Text + "%'"); this.GridView1.DataKeyNames = new string[] { "ID" }; this.GridView1.DataBind(); } if (DropDownList1.Text == "出版社地址") { Bll.PressTable bpre = new Bll.PressTable(); this.GridView1.DataSource = bpre.select("PreAddress like '%" + TextBox3.Text + "%'"); this.GridView1.DataKeyNames = new string[] { "ID" }; this.GridView1.DataBind(); } if (DropDownList1.Text == "出版社电话") { Bll.PressTable bpre = new Bll.PressTable(); this.GridView1.DataSource = bpre.select("PreTel like '%" + TextBox3.Text + "%'"); this.GridView1.DataKeyNames = new string[] { "ID" }; this.GridView1.DataBind(); } this.Label4.Text = ""; } else { this.Label4.Text = "不能为空"; } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { Bll.PressTable bpre = new Bll.PressTable(); // bpre.delete (GridView1 .DataKeys [e .RowIndex].Value .ToString ()); bpre.delete(Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString())); GridView1.EditIndex = -1; this.bind(); }
private void SetDrop() { Bll.PressTable press = new Bll.PressTable(); DropDownList1.DataSource = press.aselect(""); DropDownList1.DataValueField = "PreName"; DropDownList1.DataBind(); Bll.CategoryTable cate = new Bll.CategoryTable(); DropDownList2.DataSource = cate.aselect(""); DropDownList2.DataValueField = "BookCategory"; DropDownList2.DataBind(); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { Model.PressTable mpre = new Model.PressTable(); mpre.ID = int.Parse(GridView1.Rows[e.RowIndex].Cells[0].Text.ToString().Trim()); mpre.PreName = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text; mpre.PreAddress = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text; //mpre.PreTel = int.Parse(((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text); mpre.PreTel = Convert.ToInt32(((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text); Bll.PressTable bpre = new Bll.PressTable(); bpre.update(mpre, mpre.ID); this.GridView1.EditIndex = -1; this.bind(); }
protected void Button1_Click(object sender, EventArgs e) { Model.PressTable mpre = new Model.PressTable(); try { mpre.PreName = txtCategory.Text; mpre.PreAddress = TextBox1.Text; mpre.PreTel = int.Parse(TextBox2.Text.ToString()); Bll.PressTable bpre = new Bll.PressTable(); bpre.insert(mpre); Response.Write("<script>alert('添加成功! ')</script>"); this.bind(); } catch { Response.Write("<script>alert('添加失败!')</script>"); } }
public SqlDataReader bbang() { Bll.PressTable press = new Bll.PressTable(); return(press.aselect("")); }