|
 |
aspx thread: EditItemTemplate, label control with a text value not being chang
ed by code?
Message #1 by "Oliver, Wells" <WOliver@l...> on Thu, 29 Aug 2002 14:49:13 -0700
|
|
I have an EditItemTemplate in my Datalist with a label control:
<asp:label ID="completedDate" Text='<%# Container.DataItem ("completedDate")
%>' runat="server" />
This gives the label text the value of a DB value.
I wrote code to check and see if the value is "" and if so, supply it a new
value.
However, the control being set in the code:
CType (E.Item.FindControl ("completedDate"), Label).Text = "Test"
Doesn't overwrite the value. I think the control setting in the aspx
overrides the code behind setting it. Know a way around this?
Wells Oliver
Web Application Programmer
Leviton Voice & Data
xxx-xxx-xxxx
http://www.levitonvoicedata.com
Message #2 by "Andrew Bradnan" <andrew@w...> on Thu, 29 Aug 2002 16:46:28 -0700
|
|
You can call your own function in the OnDataBind, meaning that within
the <%# brackets %> your can put in your own function. The <%# %> just
keeps your from writing 400 OnDataBind event functions.
aspx....
<asp:label ID=3D"completedDate" Text=3D'<%# MyFunc(Container.DataItem
("completedDate"))%>' runat=3D"server" />
aspx.cs....
protected string MyFunc(object o)
{
if (o.ToString() =3D=3D string.Empty)
return "Test";
else
return o.ToString();
}
Hope that helps,
Andrew
http://whirly.info
.NET forums for programmers, stop by and say hi.
-----Original Message-----
From: Oliver, Wells [mailto:WOliver@l...]
Sent: Thursday, August 29, 2002 2:49 PM
To: ASP+
Subject: [aspx] EditItemTemplate, label control with a text value not
being chang ed by code?
I have an EditItemTemplate in my Datalist with a label control:
<asp:label ID=3D"completedDate" Text=3D'<%# Container.DataItem
("completedDate")
%>' runat=3D"server" />
This gives the label text the value of a DB value.
I wrote code to check and see if the value is "" and if so, supply it a
new
value.
However, the control being set in the code:
CType (E.Item.FindControl ("completedDate"), Label).Text =3D "Test"
Doesn't overwrite the value. I think the control setting in the aspx
overrides the code behind setting it. Know a way around this?
Wells Oliver
Web Application Programmer
Leviton Voice & Data
xxx-xxx-xxxx
http://www.levitonvoicedata.com
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=3D1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=3D1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
|
|
 |