Jun Zheng
Jun Zheng

Reputation: 677

The server tag is not well formed, ASP Repeater Datasource

I've been getting parser error with message The server tag is not well formed for the following line.

                    <asp:Repeater runat="server" DataSource="<%# ((MultilistField)((Item)Container.DataItem).Fields["Tags"]).GetItems() %>">
                    <ItemTemplate>
                        <sc:FieldRenderer ID="FieldRenderer1" runat="server" FieldName="Tag name" Item="<%# Container.DataItem %>"/>
                    </ItemTemplate>
                    <SeparatorTemplate>
                        /
                    </SeparatorTemplate>
                </asp:Repeater>

The syntax looks fine, but one thing I'm not sure about is whether you can use the ".Field["tags"] element in there.

I've tried looking it up, but couldn't find a similar problem. I'm hoping someone provide me with some insight to why the parser is complaining about this line.

Thanks

Upvotes: 5

Views: 6101

Answers (4)

vijay
vijay

Reputation: 1353

try ' instead of " it might work

else try binding from code behind

<asp:Repeater runat="server" DataSource='<%# ((MultilistField)((Item)Container.DataItem).Fields["Tags"]).GetItems() %>' >

Upvotes: 1

Oded
Oded

Reputation: 499002

You have double quotes within the attribute. This confuses the parser - it can't tell where the attribute ends.

Wrap the attribute in single quotes to fix it:

DataSource='<%# ((MultilistField)((Item)Container.DataItem).Fields["Tags"]).GetItems() %>'

Upvotes: 3

StrubT
StrubT

Reputation: 1028

What comes into my mind right now is to use a single-quoted string instead:

<asp:Repeater runat="server" DataSource='<%# ((MultilistField)((Item)Container.DataItem).Fields["Tags"]).GetItems() %>' >

Upvotes: 13

BlackSpy
BlackSpy

Reputation: 5603

Do you have a closing tag? i.e.

</asp:Repeater>

Otherwise you are missing the / at the end of your tag declaration.

<asp:Repeater runat="server" DataSource="<%# ((MultilistField)((Item)Container.DataItem).Fields["Tags"]).GetItems() %>" />

Upvotes: 0

Related Questions