Solved

Can't Update GridView

Posted on 2009-04-12
6
274 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now