Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Can't Update GridView

Posted on 2009-04-12
6
Medium Priority
?
285 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
Independent Software Vendors: 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

Technology Partners: 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!

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

618 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