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

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
R_beeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

apb2Commented:
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
R_beeAuthor Commented:
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
apb2Commented:
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
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

apb2Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
R_beeAuthor Commented:
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
apb2Commented:
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
R_beeAuthor Commented:
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
apb2Commented:
no bother buzz.

have a nice day
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.