Solved

ASP.NET : IF ELSE construct within ITEMTEMPLATE

Posted on 2003-11-20
4
2,092 Views
Last Modified: 2008-02-01
I have an IF ELSE construct within ITEMTEMPLATE as shown in the following code, but when I compile the page it is giving me the following error

Compiler Error Message: CS1525: Invalid expression term 'else'

May be it is not possible to have an if else contruct within the the asp:dataGrid tag??? any ideas

....
<asp:datagrid>
<columns>
<asp:templateColumn>
<itemtemplate>
<tr>
<td colspan=2>
<% if(Request.Params["PR"] == "VC") %>
<asp:ImageButton ID="btnUpdate_1" Runat="server" Imageurl="images/update.gif"></asp:ImageButton>
<% else %>
<asp:ImageButton ID="btnBuyNow_1" Runat="server" ImageUrl="images/buy_now.gif"></asp:ImageButton>
</td>
</tr>
</itemtemplate>
...
0
Comment
Question by:rxraza
  • 2
4 Comments
 
LVL 4

Expert Comment

by:JNSTAUB
ID: 9795432
what is the used langage (not vb, not jv so C#?)
0
 

Author Comment

by:rxraza
ID: 9797993
YES THAT is C#.
0
 
LVL 4

Assisted Solution

by:JNSTAUB
JNSTAUB earned 50 total points
ID: 9809457
<% if(Request.Params["PR"] == "VC")
response.write "<asp:ImageButton ID="btnUpdate_1" Runat="server" Imageurl="images/update.gif"></asp:ImageButton>";
else
response.write "<asp:ImageButton ID="btnBuyNow_1" Runat="server" ImageUrl="images/buy_now.gif"></asp:ImageButton>";%>
you need a ; to terminate the else statement!
0
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 150 total points
ID: 9809613
rxraza,
Try this as well :
<% if(Request.Params["PR"] == "VC")
{
%>
<asp:ImageButton ID="btnUpdate_1" Runat="server" Imageurl="images/update.gif"></asp:ImageButton>
<%
}
  else
{
%>
<asp:ImageButton ID="btnBuyNow_1" Runat="server" ImageUrl="images/buy_now.gif"></asp:ImageButton>
<%
}
%>
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now