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

Posted on 2010-01-06
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
    LVL 96

    Expert Comment

    by:Bob Learned
    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

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

    Accepted Solution

    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

    Thanks! That's just what I needed

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    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…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video discusses moving either the default database or any database to a new volume.

    760 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

    13 Experts available now in Live!

    Get 1:1 Help Now