[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 459
  • Last Modified:

EmptyDataTemplate and Detail View on new record insertion

Hi
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";
GridView1.DataBind();
}

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
0
mmalik15
Asked:
mmalik15
  • 2
1 Solution
 
DarkoLordCommented:
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
        GridView1.DataBind()
    End Sub
0
 
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.
0
 
DarkoLordCommented:
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
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now