?
Solved

BC 30205 End of statement expected......newbie problem

Posted on 2007-08-10
8
Medium Priority
?
410 Views
Last Modified: 2013-11-07
Hi

I am using asp.net for the first time and have come across this problem that I simply cannot solve.  Why am I getting this error at line 94...I cannot see anything wrong with the structure of this if / then statement?  

Error      2      End of statement expected.      W:\InetPub\wwwroot\test\Default.aspx      94      


<td><a href="Delivery.aspx?ORDER=<%#Container.DataItem("OQRIDN")%>&delivery=<%        #Container.DataItem("OQDLIX")%>"><%#Container.DataItem("OQDLIX")%></a></td>
----(line 94)----
    <td><% #If Container.DataItem("OKCUNM") = "" Then  
----(line 94)----
            Container.DataItem("OKCUNM")      
       Else
            Response.Write("&nbsp")
       #End If %></td>
<td><%#Container.DataItem("OKCUA1")%></td>
<td><%#Container.DataItem("OKCUA2")%></td>
<td><%#Container.DataItem("OKCUA3")%></td>
<td><%#Container.DataItem("OKCUA4")%></td>
<td><%#Container.DataItem("OKPHNO")%></td>
<td><%#Container.DataItem("OKTFNO")%></td>

Many Thanks in advance

Buzz
0
Comment
Question by:R_bee
  • 5
  • 3
8 Comments
 
LVL 6

Expert Comment

by:apb2
ID: 19668368
Hi Buzz

The problem is that the way you are using vb.net in HTML across multilines.

 <td><% #IIF(Container.DataItem("OKCUNM") <> "",  Container.DataItem("OKCUNM") ,  Response.Write("&nbsp")) %>
Hope that helps

apb
0
 

Author Comment

by:R_bee
ID: 19668481
Thanks apb2 I have tried this and now get this as an error

Error      2      'If', 'ElseIf', 'Else', 'End If', or 'Const' expected.      W:\InetPub\wwwroot\test\Default.aspx      94

Is IF / THEN / ELSE / END IFstructure now redundant in asp.net?  I think I have seen it elsewhere.

Many Thanks

Buzz      
0
 
LVL 6

Expert Comment

by:apb2
ID: 19668537
Hi Buzz, sorry that didn't work

Are you using a IIF and not an IF

There are quite a few things you can do here anyway.
example

 <td><% # Container.DataItem("OKCUNM") %>&nbsp;</td> this will make sure you will have at least a space in the cell.

or you can delare a protected method in your behind code

Protected function DisplayData(Byval strText As String) As String
  If strText <> "" Then
      return strText
  else
    return "&nbsp;"
End Function

<td><% # DisplayData(Container.DataItem("OKCUNM") ) %> </td>

Or if the value out of your datasource is Nothing then populate the field with a space.

One of those should work for you

apb
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Accepted Solution

by:
apb2 earned 1000 total points
ID: 19668565
Actually what am i on about.

Don't use Response.Write in html. Just use "&nbsp;". That IIF statements should work.

<td><% #IIF(Container.DataItem("OKCUNM") <> "",  Container.DataItem("OKCUNM") ,  "&nbsp") %></td>
0
 

Author Comment

by:R_bee
ID: 19668587
apb2,
        thanks that does indeed work and I will be awarding you the points....but while I have your attention and on the same subject.  Given my statement would not work, how would I do  an if / elseif / elseif / else / end if statement?

Many Thanks

Buzz
0
 
LVL 6

Expert Comment

by:apb2
ID: 19668649
Hi Buzz

Inside the HTML and inside a bound control i would probably stay clear from this type of coding.

Because .net allows you to seperate your html and server sided code i would look for solutions that didn't include in line scripting as it's easier to manage. I can't say i've ever had the need to do an if statement as in the old school Active server pages.

If this code is in a repeater or a datalist i would suggest looking into the different events that happen with these controls (OnCreate, OnDataBind) and seeing how you can manipluate the data using these events. You find them much nicer to work with and your code will be nicely seperated and hence easier to manage.

Hope that helps

apb
0
 

Author Comment

by:R_bee
ID: 19668758
apb2
   I am old school ASP and am just dipping into ASP.NET.  You have solved my initial problem and also lifted a cloud.......many thanks
0
 
LVL 6

Expert Comment

by:apb2
ID: 19668786
no bother buzz.

have a nice day
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
Suggested Courses
Course of the Month15 days, 20 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question