protected void btnAddEditor_Click(object sender, EventArgs e) { // Retrieve the previous entity DataSet DataSet dsEditor = (DataSet)Session["dsEditor"]; //Add a new entity to the business object instead of adding a row to the DataSet oEditor.NewBusinessEntity(this.oEditor.Defaults); //this.oEditor.NewRow(dsEditor, this.oEditor.TableName, new TblEditorDefaults(1, 1)); // Set the ID of the creating user oEditor.DataRow.SetField("CreateUserID", 1); // Store the DataSet back into the session Session["dsEditor"] = dsEditor; // Set the new row for editing this.dgrdEditor.EditItemIndex = dsEditor.Tables[this.oEditor.TableName].Rows.Count - 1; // Rebind the GridView this.BindControl(this.dgrdEditor); }