Solved

ASP.NET : IF ELSE construct within ITEMTEMPLATE

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Xsl Nested Loop 4 29
RSS Feeds--IE 13 178
css help 3 121
Getting Started on web Development for an experienced C++ developer 7 113
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…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

776 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