Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking 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 Basics 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
 
Old May 10th, 2006, 11:31 AM
Authorized User
 
Join Date: Jan 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default FormView Event Question

I am trying to set the value of a drop down list to null or "" after a FormView EditItemTemplate control has fully loaded. It is databound, but I need the user to change the value of the control upon an Update command. I have tried putting the code to do so in various events of the FormView.

Sub UpdateRESETUPDATEDBY()

Dim UPDATEDBYDropDownList As New DropDownList

UPDATEDBYDropDownList = FormView1.FindControl("UPDATEDBYDropDownList")

UPDATEDBYDropDownList.Text = ""

End Sub

However, when I place the code in events such as ModeChanged, or ModeChanging it gives me the following error:

Object reference not set to an instance of an object.

I don't see where there is a FormView event like the Page class has. It has the Page_LoadComplete. I think this is the type of event I am looking for, because with the other FormView events it appears that the instance of the drop down list control has not yet been created. It looks like I need an event that takes place immediately after all controls have been fully loaded, and the FormView is done loading. This would allow me to set the value.

I have also tried to use the SqlDataSource_Updating event to verify if the code works. It does, but as expected, it sets the value to null each time the FormView Update command is invoked.

Any help is greatly appreciated...

 
Old May 10th, 2006, 12:46 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Try using the RowDataBound event of the grid. Then check the rowstate if it is editmode
   if e.Row.RowState = DataControlRowState.Edit
... your code here






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 ChangeMode Question mikener ASP.NET 2.0 Professional 0 August 12th, 2008 09:30 AM
FormView and Stored Procedure question mtschindler ASP.NET 2.0 Basics 0 November 16th, 2007 05:11 PM
Event Bubbling Question Aaron Edwards ASP.NET 2.0 Professional 1 January 22nd, 2007 03:05 AM
Extra conditional update click event in FormView nuttylife2 ASP.NET 2.0 Professional 1 July 31st, 2006 08:00 PM





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