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 September 8th, 2006, 12:30 PM
Authorized User
Join Date: Nov 2005
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default FormView Label problem...

I'm having no success with a bound label in a FormView. I want the label to display the date and time when a record is edited. I've tried the Item_Updated event but nothing happens to the label. Any thoughts?

Protected Sub FormView1_ItemUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewUpdatedEventArgs ) Handles FormView1.ItemUpdated
        Dim datetime As Date
        Dim DateLabel As Label
        DateLabel = CType(FormView1.Row.FindControl("DateLabel"), Label)
        datetime = Now()
        If DateLabel Is Nothing Then
            DateLabel = New Label
            DateLabel.Text = datetime.ToLongTimeString()
            DateLabel.Text = datetime.ToLongTimeString()
        End If

    End Sub

Even if I just set the DateLabel.Text= "Hello" in the event handler, the label doesn't change in the FormView. If the bound control is Null and I exclude the If Then statement in the code, there's not even a null exception error that's thrown, causing me to think that the event is not even firing. However, if I use the FormView1_DataBinding event, the label does get updated but with every databinding event of the FormView, even if an update has occurred or not. I have no clue.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch. 4 - Adding FormView control problem donesquire BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 2 August 6th, 2010 03:56 AM
Problem in asp label vickytarun ASP.NET 1.0 and 1.1 Basics 2 November 3rd, 2007 06:17 AM
FormView/ObjectDataSource/DropDownList Problem davidanderson ASP.NET 2.0 Professional 3 April 14th, 2007 02:50 AM
DropDownList Inside FormView Problem frogosteve ASP.NET 2.0 Basics 0 April 12th, 2007 10:30 AM
Set Session to FormView Label sterreyl ASP.NET 2.0 Basics 0 March 29th, 2007 11:16 AM

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