Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 10th, 2006, 12:31 PM
Authorized User
 
Join Date: Jan 2006
Location: , , .
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...

Reply With Quote
  #2 (permalink)  
Old May 10th, 2006, 01:46 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
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

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
FormView Question mikener ASP.NET 2.0 Professional 9 September 24th, 2008 06:39 PM
FormView ChangeMode Question mikener ASP.NET 2.0 Professional 0 August 12th, 2008 10: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 09:00 PM



All times are GMT -4. The time now is 10:40 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.