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


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)----
       #End If %></td>

Many Thanks in advance

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.

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

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

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.

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

PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

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>

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

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

R_beeAuthor Commented:
   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
no bother buzz.

have a nice day
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.