EmptyDataTemplate and Detail View on new record insertion

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 vb.net. I will appreciate any suggestions
Who is Participating?
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
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
mmalik15Author Commented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.