I am not sure I really understand why you are going about
this the way
you are; it seems like a complicated approach, but aside
from that, try
Dimming it as a 'New' label.
Larry Jones
Hydrel/AcuityBrands Lighting
-----Original Message-----
From: Carlos Ramon Lopez Midence [mailto:caralomi hotmail.com]
Sent: Friday, January 26, 2007 10:19 AM
To: aspnet-datadisplaycontrols aspadvice.com
Subject: [aspnet-datadisplaycontrols] Finding Control on
Details View
I have been trying to find a solution for the following: I
have a
DropDownList with values New, Approved, Declined with
respective 0,1,2.
I have a label that represents these numbers but I want to
read the
description not the value on the DB
Protected Sub DetailsView2_ItemUpdated(ByVal sender As
Object, ByVal e
As
System.Web.UI.WebControls.DetailsViewUpdatedEventArgs)
Dim ddlApproval As DropDownList =
CType(DetailsView2.FindControl("DropDownList1"),
DropDownList)
Dim lblApproval As Label =
CType(DetailsView2.FindControl("Label1"),
Label)
If ddlApproval.SelectedIndex = "0" Then
lblApproval.Text = "New"
Else
Response.Write("Hello")
End If
End Sub
When I run the above sub I get the following error:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the
execution of the
current web request. Please review the stack trace for more
information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object
reference not
set to an instance of an object.
Source Error:
Line 13: Dim lblApproval As Label =
CType(DetailsView2.FindControl("Label1"), Label)
Line 14: If ddlApproval.SelectedIndex =
"0" Then
Line 15: lblApproval.Text = "New"
Line 16: Else
Line 17: Response.Write("Hello")
Where at Line 15 throws the error
I have only one label control and is called
"Label1"
what I am doing wrong.... Any hep will be appreciated
Carlos
____________________________________________________________
_____
Check out all that glitters with the MSN Entertainment Guide
to the
Academy
Awards? http://movies.msn.com/movies/oscars2007/?icid=ncosc
artagline2
Need SQL Advice? http://sqladvice.com
Need RegEx Advice? http://regexadvice.com
Need XML Advice?
http://xmladvice.com
Need SQL Advice? http://sqladvice.com
Need RegEx Advice? http://regexadvice.com
Need XML Advice? http://xmladvice.com
|