Search   

Friday, February 10, 2012

Support » Support Forum

Register  Login

 Menu  
 
    

 Welcome!  
 


Welcome to the NDO support forum!

kreis.gif Please register/login at the site if you want to post a thread. We sometimes copy support mails of common interest to the forum. They appear with anonymous sender.
kreis.gif Please post your messages in English language if possible. You can do your posts also in German, we will translate your post and our answer so that all users of the forum can read your posts.
kreis.gif The forum software requires that javascript is enabled.
kreis.gif Please do not insert licence information or licence keys in forum posts.
kreis.gif If you know a good answer to a post of another user, feel free to reply!
kreis.gif The forum is monitored. We reserve the right to remove posts we consider not to be useful for other forum users.

   Print   

      
 NDO Support Forum  
 
SearchForum Home
  NDO-Forum postings in english please, if possible.  Developing with NDO  Can't update pe...
 Re: Can't update persistent object
 
 7/18/2006 12:48:39 PM
Mirko
109 posts
5th


Re: Can't update persistent object
 Modified By Mirko  on 7/18/2006 12:51:02 PM)

Hi Marc,

your code snippet doesn't show how you deal with state management in your application. I guess, that you load your object list in the Page_Load event handler. Note, that the object list isn't the same after a postback - it is refetched again. Normally you'd insert an "Edit" Column in your grid, with a link pointing to a page allowing the user to edit one item of the object list. The link to the page is encoded in the ItemDataBound event of the grid as something like that:

http://yoursite/EditItem.aspx?ItemId =33599f8e-eec6-51a0-9d17-ce789fd3e5a9

You'd write something like that:

item.Cells[2].Text = @"<a href=""EditItem.aspx?" + itemId + @""">Insert into shopping basket</a>";

with ItemId being the oid of your item. In the Page_Load event of the EditItem page you just fetch the object using FindObject:

Item i = pm.FindObject(typeof(Item), new Guid(idString));

With that you can bind the edit fields in EditItem.aspx to the properties of the item. In the submit handler you have to refetch the object and enter the values from the edit fields - note that the object doesn't live between the two postbacks, it always has to be read from the database - that's the way how ASP.NET works.

With the enterprise edition of NDO you can serialize an object graph and store it in the session data or pass it along with the request. But that gives you an advantage only with intensive testing and planning.

Regards,
Mirko

 7/18/2006 8:52:56 PM
Marc
8 posts


Re: Can't update persistent object
Hi Mirko,

sorry, my mistake, I have one ASP.NET Page (Default.aspx) which load all neccesarry User Web Controls and then call the Databinding Events at the Page_Load event:

pnlContent.Controls.Add(LoadControl(Request.Params(0).Split(CType(",", Char))(0)))

Me.DataBindChildren()

At the control I use the Databinding event of the gird to bind the data:
Protected Sub grdSalutationLetter_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdSalutationLetter.DataBinding

'This method returns a NDOArrayList grdSalutationLetter.DataSource = dblSalutationLetter.ListAll(grdSalutationLetter.PageSize)

End Sub

If I select an object which should be edited the RowEditing event is fired. I handle this like shown below:

Protected Sub grdSalutationLetter_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles grdSalutationLetter.RowEditing

sender.SelectedIndex = e.NewEditIndex
oblSalutatuionLetter.getObject(sender.DataSource(e.NewEditIndex))

DataBind()
End Sub

The Databind method is required to bind the data to a textbox within the DataBinding event:

Protected Sub tbxSalutationLetter_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles tbxSalutationLetter.DataBinding

tbxSalutationLetter.Text = oblSalutatuionLetter.SalutationLetter

End Sub

If I changed the text at the textbox a TextChanged event is fired. At that moment I set the value at the object:

Protected Sub tbxSalutationLetter_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tbxSalutationLetter.TextChanged

oblSalutatuionLetter.SalutationLetter = tbxSalutationLetter.Text

End Sub

After that I must click on an image button to save respective update the object. I handle this on the Click event:

Protected Sub ibtSaveSalutationLetter_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ibtSaveSalutationLetter.Click

oblSalutatuionLetter.Save()

grdSalutationLetter.SelectedIndex = -1

oblSalutatuionLetter = New dblSalutationLetter()

DataBind()

End Sub

With "oblSalutationLetter.Save()" I call the save method of the object at the business logic (shown above).

That's it.

Here the declaration of the object used at the control:

Private Shared oblSalutatuionLetter As New dblSalutationLetter

I see the correct Id (Guid) of the object, but no update is done.

Best Regards,

Marc Haid
 7/18/2006 9:09:54 PM
Marc
8 posts


Re: Can't update persistent object
Hi Mirko,

at the moment I do some debugging an found an error code: 94

"No Type Code for dsihDataLayer.Person.Address.ddlSalutationLetter. Check NDOTypes.xml"

I found this description at the BusinessLogic under the object:

odlSalutationLetter.NDOObjectId.Id.TypeId

Might this be responsible for my problem?

Best Regards,

Marc Haid
 7/20/2006 1:58:46 PM
Mirko
109 posts
5th


Re: Can't update persistent object
 Modified By Mirko  on 7/20/2006 1:59:40 PM)

Hi Marc,

as to the NDOTypes.xml: It seems, as if the class dsihDataLayer.Person.Address.ddlSalutationLetter is in an inheritance chain. Enable the option Use Polymorphy in the NDO Configuration dialog and enter a type list file name (which must have the name NDOTypes.xml) such, that the file resides in the same directory as your NDOMapping.xml.

as to the update problem: You have to call pm.Save() in the tbxSalutationLetter_TextChanged handler, after setting the SalutationLetter property. You have to use the same pm, as it is used in the dblSalutationLetter.ListAll function. Make the pm available as a static member of a dedicated class.

Best Regards,
Mirko

 7/22/2006 1:45:26 PM
Marc
8 posts


Re: Can't update persistent object
Hi Mirko,

thanks! It works!

Best Regards,

Marc Haid
  NDO-Forum postings in english please, if possible.  Developing with NDO  Can't update pe...
  SearchSearch  Forum HomeForum Home