AutoDataSource EntityInserted event

If I have a button (e.g. Save) on a ASP.Net webform, how do I cause it to use the

AutoDataSource EntityInserted event when it is clicked?

Thanxs.

[168 byte] By [weehyong] at [2008-2-25]
# 1

Add a buttom to the control being auto bound to by the AutoDataSource. The following adds a Save button to a FormView:

<asp:Button ID="Button1" runat="server" Text="Save" Width="100px" CommandName="Insert" BackColor="White" />

Set the CommandName to Insert. When click on the button, this control will add the entity to the EntitySet being bound to. It will also raise the AutoDataSource.EntityInserted event. So if you implemented a handler, you should being able to access the new entity. i.e.

Private Sub AutoDataSource1_EntityInserted(ByVal sender As Object,

ByVal e As Microsoft.Jasper.Web.AutoDataSourceChangedEventArgs) Handles AutoDataSource1.EntityInserted

Dim story = e.Entity

story.Topic = AutoDataSource1.GetCurrentValue(Me.Topics)

story.Submitter = AutoDataSource1.GetCurrentValue(Me.Submitters)

story.PublishedDate = Date.Now

'Add Tags for story

Dim tags = CType(Me.Stories.FindControl("Tags"), TextBox).Text

For Each tag In tags.Split(New Char() {" "}, StringSplitOptions.RemoveEmptyEntries)

Dim newTag = My.DynamicContext.Tags.Create()

newTag.Story = story

newTag.TagName = tag

Next

End Sub

In this example, the code is setting properties on the newly inserted Entity not bound to the original FormView.

Let me know if that helps.

Andy

AndrewConrad-MSFT at 2007-10-2 > top of Msdn Tech,Incubation Technologies,Project Codename: Jasper...
# 2

Andy,

Thanxs for the info!

I am working on my own set of demos to demonstrate Jasper.
Will post it up when I complete it by end of the week.

weehyong at 2007-10-2 > top of Msdn Tech,Incubation Technologies,Project Codename: Jasper...
# 3
Andrew Conrad - MSFT wrote:

Add a buttom to the control being auto bound to by the AutoDataSource. The following adds a Save button to a FormView:

<asp:Button ID="Button1" runat="server" Text="Save" Width="100px" CommandName="Insert" BackColor="White" />

Set the CommandName to Insert. When click on the button, this control will add the entity to the EntitySet being bound to. It will also raise the AutoDataSource.EntityInserted event. So if you implemented a handler, you should being able to access the new entity. i.e.

Hi Andy,

Are there any writeups on the events/associated CommandName to be used to trigger the respective AutoDataSource.Entity* events? For example, if I want to do an Update, is the command name = "Update"?

Thanxs.

weehyong at 2007-10-2 > top of Msdn Tech,Incubation Technologies,Project Codename: Jasper...