protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { obj = new clsStationary(); objPrp = new clsStationaryPrp(); objPrp.Pstationary_id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex][0]); obj.del_rec(objPrp); Free_Memory(); grid_bind(); }
protected void Btn_Submit_Update_Click(object sender, EventArgs e) { obj = new clsStationary(); objPrp = new clsStationaryPrp(); objPrp.Pstationary_name = TextBox1.Text; objPrp.Pstationary_manufacturer = TextBox2.Text; objPrp.Pstationary_purchase_date = Convert.ToDateTime(TextBox3.Text); objPrp.Pstationary_purchase_file_number = TextBox4.Text; if (TextBox5.Text != "") { objPrp.Pstationary_quantity = Convert.ToInt32(TextBox5.Text); } else { objPrp.Pstationary_quantity = null; } if (CheckBox1.Checked == false) { objPrp.Pstationary_emp_id = Convert.ToInt32(DropDownList1.SelectedValue); } if (Btn_Submit_Update.Text == "Save") { obj.save_rec(objPrp); TextBox1.Focus(); } else if (Btn_Submit_Update.Text == "Update") { objPrp.Pstationary_id = Convert.ToInt32(ViewState["Index_Of_Editing_Row"]); obj.upd_rec(objPrp); Btn_Submit_Update.Text = "Save"; Btn_Reset_Cancel.Text = "Reset"; Label1.Visible = false; //ID text Label2.Visible = false; //ID value } clear_rec(); grid_bind(); Free_Memory(); }
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { obj = new clsStationary(); objPrp = new clsStationaryPrp(); //e.Cancel = true; Label1.Visible = true; //ID text Label2.Visible = true; //ID value //ViewState["Index_Of_Editing_Row"] = Convert.ToInt32(GridView1.DataKeys[e.NewEditIndex][0]); ViewState["Index_Of_Editing_Row"] = objPrp.Pstationary_id = Convert.ToInt32(GridView1.DataKeys[e.NewEditIndex][0]); objPrp = obj.find_rec(objPrp); Label1.Text = "ID"; Label2.Text = Convert.ToString(objPrp.Pstationary_id); TextBox1.Text = objPrp.Pstationary_name; TextBox2.Text = objPrp.Pstationary_manufacturer; TextBox3.Text = Convert.ToString(objPrp.Pstationary_purchase_date).Substring(0, 10); TextBox4.Text = objPrp.Pstationary_purchase_file_number; TextBox5.Text = Convert.ToString(objPrp.Pstationary_quantity); if (objPrp.Pstationary_emp_id != 0) { DropDownList1.SelectedValue = objPrp.Pstationary_emp_id.ToString(); CheckBox1.Checked = false; DropDownList1.Enabled = true; } else { CheckBox1.Checked = true; DropDownList1.Enabled = false; } Btn_Submit_Update.Text = "Update"; //Btn_Cancel.Visible = true; Btn_Reset_Cancel.Text = "Cancel"; Free_Memory(); }
private void Free_Memory() { objPrp = null; obj = null; GC.Collect(); }