?
Solved

Can't Update GridView

Posted on 2009-04-12
6
Medium Priority
?
283 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 4

Accepted Solution

by:
newbieal earned 1500 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Assisted Solution

by:newbieal
newbieal earned 1500 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

770 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