Asp.Net News
Free Tech Magazines
Asp.Net Web Hosting
Suggest Us
Link to Us
Feeds Subscription
Questions & Answers
Tips & Tricks
 Problem when using the code given in the article - 'Simple Insert, Update, Delete in GridView'
Posted by Anandi.A on  7/18/2007 11:17:46 PM Category: ADO.NET
Add to my favorites
Email to friend

I have tried using the code given in the article. When I click on Edit link, Update and Cancel links are appearing and the drop down list is also appearing which I have put in the Edit Template column. But after I select a value from the dropdown list and click update, the dropdown list is still visible. But after if I click Cancel, list disppears and the GridView is bound with the updated value.

When I debugged it, I saw that after the Rowupdating method is called, Row data bound event is also called and there the Dropdownlist is not null. So data binding happens to the Dropdownlist.Is this a problem?

But the Cancel link is working fine. (There when it goes to RowDataBound method is called the Dropdownlist is null.)

Please help.

Post Your Reply Post New Question

 Viewer's Reply
Add GridView1.EditIndex = -1;
Answered By Moderator1 on 7/19/2007 11:15:37 AM

In your GridView1_RowUpdating event, after updating your record into database and before fetching it again to fill the GridView control, you have to add the following code

GridView1.EditIndex = -1;

We hope it will work. Otherwise inform us.. sure we will guide you.

Post Your Reply If you still have problem, post it again under this reply for better response.

Sponsored by
Introduction to Web Applications Development
The Beginner's Guide to Joomla
Integrating Silverlight 4 with SharePoint 2010 - Free 42 Page Sample Chapter