?
Solved

ASP.NET : IF ELSE construct within ITEMTEMPLATE

Posted on 2003-11-20
4
Medium Priority
?
2,179 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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 600 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

800 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