Use a combination of double and single quotes:
Text='<%# DataBinder.Eval(Container.DataItem, "EntryText") %>'
Вопрос
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 LinkButton
s 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?
Решение
Use a combination of double and single quotes:
Text='<%# DataBinder.Eval(Container.DataItem, "EntryText") %>'
Другие советы
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")%>'