DataBinder.Eval question

C

Chris

I have a class method that returns a DataSet.

I use bind this to my Repeater control.
Inside the Repeater i have

<ItemTemplate>
<li><%# DataBinder.Eval(Container.DataItem, "name") %> <%#
DataBinder.Eval(Container.DataItem, "enabled") %></li>
</ItemTemplate>

I want to include a checkbox that will be 'checked' when enabled='t'. I
don't want to use the asp:Checkbox control as i will be doing custom
form submission on change.

I notice i cannot do:
<input type="checkbox" value="t" <%# if (DataBinder.Eva(Container.DataItem,
"enabled") == 't') { Response.Write("checked"); } %> />

So i'm after suggestions as to how i can achieve this?

Thanks
Chris
 
G

Guest

Hi, Chris

You might try adding a calculated column to your dataset
ds.Columns.Add("Checked", System.Type.GetType("System.String"), "IIF(enabled='t', 'Checked', '')"

<input type="checkbox" value="t" <%# DataBinder.Eval(Container.DataItem,"Checked") %> /

Bin Song, MCP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top