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.
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.
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,
Dim story = e.EntityByVal e As Microsoft.Jasper.Web.AutoDataSourceChangedEventArgs) Handles AutoDataSource1.EntityInserted
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).TextFor Each tag In tags.Split(New Char() {" "}, StringSplitOptions.RemoveEmptyEntries)
Dim newTag = My.DynamicContext.Tags.Create()
newTag.Story = story
newTag.TagName = tag
Next
End SubIn 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
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.
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.