protected void btnadd_Click(object sender, EventArgs e) { PubAdapter.Insert(txtpub.Text); lblmsg.Text = "Publication Added Successfully !!"; PubDT = PubAdapter.Select(); GridView1.DataSource = PubDT; GridView1.DataBind(); txtpub.Text = ""; txtpub.Focus(); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { int pid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value); TextBox pname = GridView1.Rows[e.RowIndex].Cells[2].Controls[0] as TextBox; PubAdapter.Update(pid, pname.Text); lblmsg.Text = "Publication Updated"; GridView1.EditIndex = -1; PubDT = PubAdapter.Select(); GridView1.DataSource = PubDT; GridView1.DataBind(); }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int bid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value); PubDT = PubAdapter.Select_By_PID(bid); BDT = BAdapter.Select_By_Publication(PubDT.Rows[0]["publication"].ToString()); if (BDT.Rows.Count > 0) { lblmsg.Text = "Please delete first books"; } else { PubAdapter.Delete(bid); lblmsg.Text = "Publication Deleted"; PubDT = PubAdapter.Select(); GridView1.DataSource = PubDT; GridView1.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { lblmsg.Text = ""; lblmsg0.Text = ""; if (Page.IsPostBack == false) { BDT = BAdapter.SelectBranch(); drpbranch.DataSource = BDT; drpbranch.DataTextField = "Branchname"; drpbranch.DataValueField = "Branchid"; drpbranch.DataBind(); drpbranch.Items.Insert(0, "SELECT"); MultiView1.ActiveViewIndex = -1; PubDT = PubAdapter.Select(); drppublication.DataSource = PubDT; drppublication.DataTextField = "Publication"; drppublication.DataValueField = "pid"; drppublication.DataBind(); drppublication.Items.Insert(0, "SELECT"); } }