Solved

ASP.NET : IF ELSE construct within ITEMTEMPLATE

Posted on 2003-11-20
4
2,132 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

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

Suggested Solutions

Title # Comments Views Activity
Share post from Facebook Tab Application 6 41
Forbidden errors 5 152
Problem to echo 6 109
What does GoogleTagMgr javascripts below do 5 29
When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

839 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