質問

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?

役に立ちましたか?

解決

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")%>'
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top