EmptyDataTemplate and Detail View on new record insertion

Posted on 2007-07-26
Last Modified: 2013-12-25
I am using EmptyDataTemplate to insert record via a detailview. I manage to add a new record but i cud not find a solution after record insertion to rebind my Grid. On one of the examples online i found that i can re bind on this event like this

protected void DetailsView1_ItemInserted
(object sender, DetailsViewInsertedEventArgs e)
GridView1.DataSourceID = "SqlDataSource1";

but i cud not get into this event in the code behind page. If i manually type this event; control does not go inside the code. Any ideas how can i re bind my grid after inserting through detail view in emptydatatemplate. I am using VS 2005 with I will appreciate any suggestions
Question by:mmalik15
    LVL 22

    Expert Comment

    As you are using VB.NET instead of C# (in which the code you pasted is written) it should look like this:

        Protected Sub DetailsView1_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs) Handles DetailsView1.ItemInserted
        End Sub

    Author Comment

    i am getting an error when i type this code i.e.
    Handles clause requires a WithEvents variable defined in the containing type or one of its base types.
    LVL 22

    Accepted Solution

    Open the web form in the design view, select the DetailsView, press F4 to go to the property editor, click the "lightning bolt" icon in the property editor and double click the ItemInserted event - the procedure should then be created automatically

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now