Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 12th, 2008, 09:30 AM
Authorized User
 
Join Date: Sep 2005
Location: , , .
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default FormView ChangeMode Question

I have a formview that is bound to an object data source. Depending on whether or not a database row is found I want to change the mode from Read Only to either Edit or Insert. In order to do this I have the following code:

protected void FormView1_DataBound(object sender, EventArgs e)
{
        if (FormView1.DataItemCount == 0)
        {
             FormView1.ChangeMode(FormViewMode.Insert);
        }
        else
        {
             FormView1.ChangeMode(FormViewMode.Edit);
        }
}

The problem that I am facing is that when a row exists in the database, changing the mode to Edit causes my object data source Selecting event to run a second time. This means that the same row that was just read will be read a second time.

Is there anyway to prevent a re read of the database while still binding to the FormView?

Thanks



Similar Threads
Thread Thread Starter Forum Replies Last Post
FormView Question mikener ASP.NET 2.0 Professional 9 September 24th, 2008 05:39 PM
formview mcarol44 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 5 January 5th, 2008 06:44 AM
FormView and Stored Procedure question mtschindler ASP.NET 2.0 Basics 0 November 16th, 2007 05:11 PM
using FindControl after ChangeMode in a FormView pbb ASP.NET 2.0 Basics 1 March 6th, 2007 10:11 AM
FormView Event Question melbsurfer ASP.NET 2.0 Basics 1 May 10th, 2006 12:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.