namespace MMSS.StandardsStudio.Business { /// <summary> /// Summary description for tblClass. /// </summary> public class tblClass : ABusinessObject { public tblClass() { // set class props this.RetrieveAutoIncrementPK = true; this.TableName = "tblClass"; this.PrimaryKey = "ClassID"; this.UpdateSelectStatement = "SELECT * FROM tblClass"; } /// <summary> /// Returns a dataset of top level Kingdoms /// </summary> public DataSet GetKingdoms() { return this.GetDataSet("SELECT * FROM tblClass WHERE ParentClassID = 0 ORDER BY ClassName "); } etc....The Page Load code is as follows;
private void Page_Load(object sender, System.EventArgs e) { // tblClass BO this.otblClass = (tblClass)this.RegisterBizObj(new tblClass()); DataSet DS = this.otblClass.GetEmptyDataSet("tblClass"); this.otblClass.SetCurrentDataSet(DS); // add an empty row DataRow dr = this.otblClass.NewRow("tblClass"); if (dr != null) { //this.otblClass.DataRow = dr; this.otblClass.LoadRow(0); // don't understand this, can't run without this line, combo's break ??? } Session["tblClass"] = this.otblClass.GetCurrentDataSet(); etc...How can I load the new empty row using this.otblclass.loadrow() Or do I need to do that at all? There is more load code but it just sets up other BO's. At this point the page is ready to be edited and posted back. I make edits and click the Save button which executes my example Save code. More questions I have are in the inline comments.
private void btnSave_Click(object sender, System.EventArgs e) { //this.otblClass.SaveRow(); // is this the right place for this??? Or necessary at all? DataSet dsClass = (DataSet)Session["tblClass"]; // are my edits/changes on the page included in the retrieved Session["tblClass'] here??? if (dsClass != null) { //this.otblClass.UpdateFromDataSet(dsClass); // how is this different from SaveDataSet()??? //this.otblClass.SaveDataSet(dsClass); } etc...I have tried to use just the BO methods to complete the task but don't know how to do it without some help. I'm confused about where the data actually is on the postback and which methods to call and when to call them. Can you please help?