Solved

Can't Update GridView

Posted on 2009-04-12
6
279 Views
Last Modified: 2012-05-06
I have a GridView bound to a SQL Server DataSource.  All the data renders from that souce into the bound grid.  I've made the grid editable, so when I hit "Edit", the one field I want to be edited is enabled.  When I put in the new value and hit update, absolultely nothing happens.

The attached file shows my update query.  There's not much to it.  I map the "Quantity" field in the grid to the "QUantity" field in the database.  When I hit "execute query", the value I put in manually in this window indeed DOES get written to the database.  However, when I update a single row, not only does that value not get written to all rows (as in my test), but nothing gets updated anywhere.

I'm almost there.  What grand avatar can guide me to the ever-elusive grail of actually being able to update a datasource?
Image.jpg
0
Comment
Question by:NigelRocks
  • 3
  • 3
6 Comments
 
LVL 4

Accepted Solution

by:
newbieal earned 500 total points
ID: 24127847
You have to complete the SQL statement add a where clause, something like:
WHERE some_column=some_value

Otherwise how does it know which record in the db to update?

I believe it works in the query builder, because it knows the record to update (by default the first one in the table, possibly?), but in the gridview it doesn't know.
0
 
LVL 1

Author Comment

by:NigelRocks
ID: 24129136
I thought of that and added the WHERE clause later.  Still doesn't work.
0
 
LVL 1

Author Comment

by:NigelRocks
ID: 24129839
The attached image shows my settings in the query window.  What am I missing?
Image.jpg
0
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.

 
LVL 4

Assisted Solution

by:newbieal
newbieal earned 500 total points
ID: 24130224
Did you add breakpoints in your code to see if the update event/method(s) are firing at all?
0
 
LVL 1

Author Closing Comment

by:NigelRocks
ID: 31569396
The actual problem was that I had a DataBind() method being called on postback. This loaded the old data back into the grid.  Once I took it out, the grid was updated without a problem.
0
 
LVL 4

Expert Comment

by:newbieal
ID: 24130584
Glad you found the source of the issue and were able to resolve it.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

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