Logo 
Search:

Asp.net Answers

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds
  Question Asked By: Trupti Patil   on Feb 06 In Asp.net Category.

  
Question Answered By: Alan Palmer   on Feb 06

The problem  is that you're using this syntax  <% %> which doesn't work as
databinding, so you don't have access to Container.DataItem (the item
bounded). This syntax <%# .... %> is used for databinding purpose

So what you would have to do is


<asp:DataList ...>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "bBooleanField") %><br/>
<%# Convert.ToBoolean(DataBinder.Eval(Container.DataItem,
"bBooleanField")).ToString() %>
</ItemTemplate>
</asp:DataList>

Note this:

DataBinder.Eval(Container.DataItem, "bBooleanField")

this return an Object type, so you would have to use Convert.ToBoolean
to get a Boolean type  and then use the ToString() method of the Boolean
type to get True or False

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on problem with conditional output in templates Or get search suggestion and latest updates.


Tagged: