Solved

Insert using DetailsView doesn't update the GridView on same page.

Posted on 2010-09-23
1
441 Views
Last Modified: 2013-11-05
Hi

I have a DetailsView for Inserting new records and a GridView for edting and deleting records - they are both using the same datasource (they are all contacts from the same company.  However, once a new record (contact) has been added via the DetailsView, the GridView is not rebound.  I have tried refreshing the page but the new record still doesn't show in the GridView.  If I come out of the page and go back in, they are all there.  What else do I have to do in my code to get them to show automatically after insert??  I am using .net 2.0 and I'm not using code behind (can do if necessary I'm sure).  Thanks Lorna
0
Comment
Question by:Lorna70
1 Comment
 
LVL 15

Accepted Solution

by:
crisco96 earned 250 total points
ID: 33745159
What you need to do is rebind the gridview.

I would suggest creating a code behind page for this.

Basically you need to wire up an event in the DetailsView for OnItemInserted. In your event handler (which will be in the code behind) just make a call to the DataBind() method in your gridview, so if your gridview's ID is GridView1 you'll do GridView1.DataBind()
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

821 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