Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADO.Net and MM BO's
Message
From
05/03/2004 17:16:34
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
ADO.Net and MM BO's
Miscellaneous
Thread ID:
00883709
Message ID:
00883709
Views:
45
Hi All MM Users!

I am building an add record page. I need some help figuring out how to use the MM Business Object methods to add a new empty row to a dataset, edit the data on the page with MM bound controls and then save form data to the dataset using BO methods. Seems like a simple task, but I've not been able to find the exact sequence of steps to be successful. I want to use the BO methods even though I know I could call a sproc to add a new row and retrieve the generated PK and then make another sproc call to load that new (empty) row into the dataset for the page.

I have an auto-incrementing PK in my SQL table and have 3 FK's in the table. My page has 3 dropdown lists for those fks's and some check boxes and textbox controls. The data binding is all setup per the Dev Guide and appears to be working just fine in terms of the dropdowns being populated as expected and the fields allow edits when the page is loaded.

The BO is setup similarly to the following;
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?
Kendall Webb
Senior Software Engineer
MCAD.Net/MCSD.Net
Next
Reply
Map
View

Click here to load this message in the networking platform