0

The scenario I'm dealing with is I have a set of entries in a database that have an image associated with them. This image needs to be 'accepted' or 'rejected' via a web interface.

I'm using ASP.NET WebForms.

I'm attempting to databind my recordset of entires to a CheckBoxList control. I would like to combine data from my dataset with information from the web.config file and plain text to display an image:

<asp:CheckBoxList ID="CheckBoxList1" runat="server" 
    DataSourceID="DataSource1" 
    DataTextField="ImageIdentifier" 
    DataValueField="EntryId"        
    DataTextFormatString="<img src='<%$ AppSettings:GetImageUrl %>{0}' />" />

This approach correctly outputs the plain text and the DataTextField value, however it does not interpret the code inside the <% %> block and prints the whole thing literally in the generated HTML, in spite of it being correctly highlighted in the editor.

Is this possible to achieve declaratively? If not, is there a better way than iterating through the entries in the list in code on the OnDataBound event?

Thanks in advance,

Jamie

4

2 回答 2

1

我相信您使用了错误的 <% 标签。为了在这样的绑定表达式中进行评估,它应该是 <%#

于 2010-01-23T16:02:58.073 回答
0

您的 web.config 是什么样的?您将无法在此处使用该绑定语法 - 您必须挂钩复选框的数据绑定事件并迭代每个复选框,并根据需要从 web.config 中的值更新它们。

编辑

如果您不想在复选框列表数据绑定后迭代每个复选框,则必须先更新您的数据集,然后再绑定到它。

于 2009-06-16T11:32:26.110 回答