Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


How do I leave a field unchanged when updating a row in a Gridview

Posted on 2010-01-06
Medium Priority
Last Modified: 2012-05-08
The gridview I'm using has 3 fields that can be updated. There is a Priority field that will be set to a different value if the user enters a close date. If the close date isn't enetered, the Priority should be unchanged.
What's happening now is that if I enter some notes and click update, the Priority gets set to null instead of retaining its original value.
Is there a way to keep the old value if there is no new value? I'm also using a sqldatasource.
Question by:lakhi
  • 2
  • 2
LVL 96

Expert Comment

by:Bob Learned
ID: 26191565
You might be able to work around this by dynamically changing the SqlDataSource.UpdateCommand, based on whether you have a close date or not.

Author Comment

ID: 26192062
Is there an example of this somewhere? It would really be helpful.
LVL 96

Accepted Solution

Bob Learned earned 2000 total points
ID: 26192126
You need to figure out when you want to do this, but it is as easy as this:

C# example:

this.SqlDataSource1.UpdateCommand = string.Format("UPDATE Employee SET DateHired = '{0}' ",

Author Closing Comment

ID: 31673473
Thanks! That's just what I needed

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
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.…
Integration Management Part 2
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

571 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