Frage

I have a repeater like the following,

<asp:Repeater ID="rptEntries" runat="server">                         
    <ItemTemplate>
         <asp:LinkButton ID="lnk1" runat="server" Text=""></asp:LinkButton>
    </ItemTemplate>
</asp:Repeater>

Now, I want to bind the Text value of LinkButtons with the following,

<%# DataBinder.Eval(Container.DataItem, "EntryText") %>

However, I get the double quotes problems, when I do the following,

Text="<%# DataBinder.Eval(Container.DataItem, "EntryText") %>"

How to solve this issue?

War es hilfreich?

Lösung

Use a combination of double and single quotes:

Text='<%# DataBinder.Eval(Container.DataItem, "EntryText") %>'

Andere Tipps

You could do

((ContainerType)Container.DataItem)).EntryText

So it'll look like this

Text='<%# ((ContainerType)Container.DataItem)).EntryText %>'

where ContainerType is the type of that object. It is actually more efficient that way because it won't have to be evaluated using the "Eval" method.

Otherwise use single quote followed by double quote.

Text='<%# DataBinder.Eval(Container.DataItem, "EntryText") %>'

This may solve the issue

Try this;

Text='<%#DataBinder.Eval(Container.DataItem, "EntryText")%>'
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top