This is what someone else told me to use and it worked. Gozirra, thanks for
your help!!!
Dim YTDLabel As Label
YTDLabel = DirectCast(FormView1.FindControl("YTDLabel"), Label)
Dim YTDtest As Decimal
YTDTest = Decimal.Parse(YTDLabel.Text)
"Gozirra" <> wrote in message
news: ps.com...
> The type is a Decimal. Decimal.Parse converts the value of the labels
> text property to a decimal type and assigns it to your variable. I
> have tested a very simple example of this to make sure it works and
> have had no problems. Can you step through the code and see what's
> going on? I wonder if the FormView is causing problems. My small
> sample does not use a FormView and works perfectly.
>
> Phillip Vong wrote:
>> Maybe I just don't understand. I tried your code this way and nothing
>> happend. I don't think it's test to see if the value is > 0 because it's
>> now a text format. Am I right about that? How do you make it test to
>> see
>> if the decimal value is greater than 1?
>>
>> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>> System.EventArgs)
>>
>> Dim YTDtest As Decimal
>>
>> YTDtest = Decimal.Parse(CType(FormView1.FindControl("YTDLabe l"),
>> Label).Text)
>>
>> If YTDtest > 0 Then
>>
>> FormView1.FindControl("YTDLabel").Visible = False
>>
>> End If
>>
>> End Sub
>>
>>
>>
>>
>>
>>
>> "Gozirra" <> wrote in message
>> news: oups.com...
>> > YTDtest is a Decimal variable. The returned value of FindControl is a
>> > control object. These are obviously not the same thing. I think what
>> > you are wanting to do is get the Text property of the control and
>> > assign it to the YTDtest variable.
>> >
>> > Try
>> > YTDtest = Decimal.Parse(CType(FormView1.FindControl("YTDLabe l"),
>> > Label).Text)
>> >
>> > And you may not need to use FindControl. If the control is declared in
>> > the code beind, you can access it directly.
>> > YTDtest = Decimal.Parse(YTDLabel.Text)
>> >
>
|