473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Syntax Problem

I am working through some ASP.NET tutorials and trying to adapt some of them
to my data. I built an aspx page that pulls data from an SQL server with a
query and use a repeater control to display it. As long as I use the format
of:

<ItemTemplate>
<tr bgcolor="#f0f0f0">
<td><%#Container.DataItem("CircuitName")%> </td>
<td><%#Container.DataItem("CircuitCity")%> </td>
<td><%#Container.DataItem("CircuitState")%> </td>

things work great but I need to apply some processing to some of the data
and when I try code like:

<%
If (Len(#Container.DataItem("WebPageURL")) <2) Then
Response.Write( "<td>None Given</td>")
Else
........

I get errors such as the following:

Compiler Error Message: BC30201: Expression expected.

Source Error:

Line 54: <%
Line 55: Dim tmpSTR
Line 56: If (Len(#Container.DataItem("WebPageURL")) <2) Then
Line 57: Response.Write( "<td>None Given</td>")
Line 58: Else

It appears that it doesn't like the way I am trying to check the length of
the field.

Any pointers to how this should be done?

TIA

Wayne

Nov 18 '05 #1
3 1277
You need to wrap your dataitem value with a function call

<%#BOB(Container.DataItem("CircuitName").ToString( ))%>

Sorry (not very up on VB.NET.so syntax might be a bit wierd but you'll get
the idea

Function bob(string fred)
If (Len fred)) <2) Then
Return( "<td>None Given</td>")
End If
End Function

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:uP**************@TK2MSFTNGP11.phx.gbl...
I am working through some ASP.NET tutorials and trying to adapt some of them to my data. I built an aspx page that pulls data from an SQL server with a
query and use a repeater control to display it. As long as I use the format of:

<ItemTemplate>
<tr bgcolor="#f0f0f0">
<td><%#Container.DataItem("CircuitName")%> </td>
<td><%#Container.DataItem("CircuitCity")%> </td>
<td><%#Container.DataItem("CircuitState")%> </td>

things work great but I need to apply some processing to some of the data
and when I try code like:

<%
If (Len(#Container.DataItem("WebPageURL")) <2) Then
Response.Write( "<td>None Given</td>")
Else
.......

I get errors such as the following:

Compiler Error Message: BC30201: Expression expected.

Source Error:

Line 54: <%
Line 55: Dim tmpSTR
Line 56: If (Len(#Container.DataItem("WebPageURL")) <2) Then
Line 57: Response.Write( "<td>None Given</td>")
Line 58: Else

It appears that it doesn't like the way I am trying to check the length of
the field.

Any pointers to how this should be done?

TIA

Wayne

Nov 18 '05 #2
The problem here is the mixture of declarative and programatic logic. This
does not work with data-binding. You can bind to a function call, as John
(another response to your post) has mentioned, which is a good compromise.

I think the following is a bit more correct VB.NET syntax:

Protected Function BOB(fred As String)

'To get rid of magic strings
Const returnString As String = "<td>None Given</td>"

'Opted for .NET version, rather than VB LEN() function
If (fred.Length < 2) Then
Return returnString
Else
Return fred
End If

End Function

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:uP**************@TK2MSFTNGP11.phx.gbl...
I am working through some ASP.NET tutorials and trying to adapt some of them to my data. I built an aspx page that pulls data from an SQL server with a
query and use a repeater control to display it. As long as I use the format of:

<ItemTemplate>
<tr bgcolor="#f0f0f0">
<td><%#Container.DataItem("CircuitName")%> </td>
<td><%#Container.DataItem("CircuitCity")%> </td>
<td><%#Container.DataItem("CircuitState")%> </td>

things work great but I need to apply some processing to some of the data
and when I try code like:

<%
If (Len(#Container.DataItem("WebPageURL")) <2) Then
Response.Write( "<td>None Given</td>")
Else
.......

I get errors such as the following:

Compiler Error Message: BC30201: Expression expected.

Source Error:

Line 54: <%
Line 55: Dim tmpSTR
Line 56: If (Len(#Container.DataItem("WebPageURL")) <2) Then
Line 57: Response.Write( "<td>None Given</td>")
Line 58: Else

It appears that it doesn't like the way I am trying to check the length of
the field.

Any pointers to how this should be done?

TIA

Wayne

Nov 18 '05 #3
Thanks for the responses guys. I need to do some reading. Some things in
..NET are so intuitive and then there are some that are hard to grasp!

Wayne
"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:uP**************@TK2MSFTNGP11.phx.gbl...
I am working through some ASP.NET tutorials and trying to adapt some of them to my data. I built an aspx page that pulls data from an SQL server with a
query and use a repeater control to display it. As long as I use the format of:

<ItemTemplate>
<tr bgcolor="#f0f0f0">
<td><%#Container.DataItem("CircuitName")%> </td>
<td><%#Container.DataItem("CircuitCity")%> </td>
<td><%#Container.DataItem("CircuitState")%> </td>

things work great but I need to apply some processing to some of the data
and when I try code like:

<%
If (Len(#Container.DataItem("WebPageURL")) <2) Then
Response.Write( "<td>None Given</td>")
Else
.......

I get errors such as the following:

Compiler Error Message: BC30201: Expression expected.

Source Error:

Line 54: <%
Line 55: Dim tmpSTR
Line 56: If (Len(#Container.DataItem("WebPageURL")) <2) Then
Line 57: Response.Write( "<td>None Given</td>")
Line 58: Else

It appears that it doesn't like the way I am trying to check the length of
the field.

Any pointers to how this should be done?

TIA

Wayne

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
24
by: Andrew Koenig | last post by:
PEP 315 suggests that a statement such as do: x = foo() while x != 0: bar(x) be equivalent to while True:
35
by: Moosebumps | last post by:
Does anyone here find the list comprehension syntax awkward? I like it because it is an expression rather than a series of statements, but it is a little harder to maintain it seems. e.g. you...
23
by: C. Barnes | last post by:
I vote for def f(): (body of function) This is backwards compatible (Python <= 2.3 raise SyntaxError), and looks much nicer than @. The only problem is that you can't one-line a...
16
by: George Sakkis | last post by:
I'm sure there must have been a past thread about this topic but I don't know how to find it: How about extending the "for <X> in" syntax so that X can include default arguments ? This would be very...
29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
5
by: NanQuan | last post by:
I'm hoping someone can help me solve this error since I am at a total loss here. Usually I don't bother posting on any forums or groups on the internet and prefer to solve stuff myself but this is...
19
by: Nicolas Fleury | last post by:
Hi everyone, I would to know what do you think of this PEP. Any comment welcomed (even about English mistakes). PEP: XXX Title: Specialization Syntax Version: $Revision: 1.10 $...
20
by: W Karas | last post by:
Would the fear factor for concepts be slightly reduced if, instead of: concept C<typename T> { typename T::S; int T::mem(); int nonmem(); };
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.