|
 |
aspx thread: RE: EditItemTemplate, label control with a text value
not being chang ed by code?
Message #1 by "Oliver, Wells" <WOliver@l...> on Tue, 3 Sep 2002 14:36:41 -0700
|
|
Any idea how this function might be done in VB.NET?
I have tried:
Public Sub checkDateLabel (S as Object)
' Checks the date
If (S.ToString () = String.Empty)
Return "Sorry"
Else
Return S.ToString()
End If
I realize this probably rather simple :) Thanks!
-----Original Message-----
From: Andrew Bradnan [mailto:andrew@w...]
Sent: Thursday, August 29, 2002 4:46 PM
To: ASP+
Subject: [aspx] RE: EditItemTemplate, label control with a text value not
being chang ed by code?
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="completedDate" Text='<%# MyFunc(Container.DataItem
("completedDate"))%>' runat="server" />
aspx.cs....
protected string MyFunc(object o)
{
if (o.ToString() == 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="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
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
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.
---
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
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.
---
Message #2 by "Andrew Bradnan" <andrew@w...> on Wed, 4 Sep 2002 10:52:58 -0700
|
|
What's the error?
I think you are just missing the return type. I have trouble not typing
the semi-colon :S
Public Function checkDateLabel (S as Object) as String
' Checks the date
If (S.ToString () =3D String.Empty)
Return "Sorry"
Else
Return S.ToString()
End If
End Function
Try that.
-----Original Message-----
From: Oliver, Wells [mailto:WOliver@l...]
Sent: Tuesday, September 03, 2002 2:37 PM
To: ASP+
Subject: [aspx] RE: EditItemTemplate, label control with a text value
not being chang ed by code?
Any idea how this function might be done in VB.NET?
I have tried:
Public Sub checkDateLabel (S as Object)
' Checks the date
If (S.ToString () =3D String.Empty)
Return "Sorry"
Else
Return S.ToString()
End If
I realize this probably rather simple :) Thanks!
-----Original Message-----
From: Andrew Bradnan [mailto:andrew@w...]
Sent: Thursday, August 29, 2002 4:46 PM
To: ASP+
Subject: [aspx] RE: EditItemTemplate, label control with a text value
not
being chang ed by code?
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.
---
---
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.
---
---
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.
---
|
|
 |