Solved

ASP.NET : IF ELSE construct within ITEMTEMPLATE

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
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…

687 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