Solved

Can't Update GridView

Posted on 2009-04-12
6
281 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 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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