A
Aleko Petkov
Hi,
I want to display different content in a DataGrid row, depending on the
value returned by a DataBinder. I am trying to write something like this:
<ItemTemplate>
<% if( DataBinder.Eval(Container.DataItem, "UserID") > 0 ) { %>
<asp:Hyperlink ... />
<% } else { %>
<asp:Literal ... />
% } %>
</ItemTemplate>
Basically if the current row's UserID field is greater than zero, display a
hyperlink. Otherwise, just display some static text.
If I run this, ASP.NET complains that it doesn't know what Container is. If
I add a # just after the first <% tag, it then says that if statements are
illegal.
So,
1. Is it possible to do this, or do I have to move the DataBinder code to
function in the code-behind?
2. What is the # sign for, anyway? I can't find anything information about
it in the documentation.
Thanks,
Aleko
I want to display different content in a DataGrid row, depending on the
value returned by a DataBinder. I am trying to write something like this:
<ItemTemplate>
<% if( DataBinder.Eval(Container.DataItem, "UserID") > 0 ) { %>
<asp:Hyperlink ... />
<% } else { %>
<asp:Literal ... />
% } %>
</ItemTemplate>
Basically if the current row's UserID field is greater than zero, display a
hyperlink. Otherwise, just display some static text.
If I run this, ASP.NET complains that it doesn't know what Container is. If
I add a # just after the first <% tag, it then says that if statements are
illegal.
So,
1. Is it possible to do this, or do I have to move the DataBinder code to
function in the code-behind?
2. What is the # sign for, anyway? I can't find anything information about
it in the documentation.
Thanks,
Aleko