467,099 Members | 1,124 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,099 developers. It's quick & easy.

Data Binding in a Repeater

I'm having trouble with my repeater:

I'm binding my Repeater control to an OleDbDataReader object. My ASPX looks
like this:

<asp:Repeater ID="Rptr" runat="server">
<ItemTemplate>
<asp:Label ID="LB" runat="server" Text="" />
<br/>
<%# Eval("TextBody") %>
<br />
<%# Eval("ID") %>
<br />
<%# Eval("Owner") %>
<br />
<%# Eval("CreateDate") %>
</ItemTemplate>
</asp:Repeater>

If I do the above, all works fine. BUT, if I try to set the Text property of
a control such as...
<asp:Label ID="LB" runat="server" Text="<%# Eval("Owner") %>" />

then, I get "The server tag is not well formed" for that Label. Is this
because of the double-quotes that have to be inside the Eval("")?

Also, one other thing: How can I do date formatting for date values coming
back?

Thanks.

Alex

Jun 13 '06 #1
  • viewed: 1342
Share:
3 Replies
Experiment with single and double quotes.
<asp:Label ID="LB" runat="server" Text='<%# Eval("Owner") %>' />

or try a few different permutations.

"Alex Maghen" <Al********@newsgroup.nospam> wrote in message
news:D9**********************************@microsof t.com...
I'm having trouble with my repeater:

I'm binding my Repeater control to an OleDbDataReader object. My ASPX looks like this:

<asp:Repeater ID="Rptr" runat="server">
<ItemTemplate>
<asp:Label ID="LB" runat="server" Text="" />
<br/>
<%# Eval("TextBody") %>
<br />
<%# Eval("ID") %>
<br />
<%# Eval("Owner") %>
<br />
<%# Eval("CreateDate") %>
</ItemTemplate>
</asp:Repeater>

If I do the above, all works fine. BUT, if I try to set the Text property of a control such as...
<asp:Label ID="LB" runat="server" Text="<%# Eval("Owner") %>" />

then, I get "The server tag is not well formed" for that Label. Is this
because of the double-quotes that have to be inside the Eval("")?

Also, one other thing: How can I do date formatting for date values coming
back?

Thanks.

Alex

Jun 14 '06 #2
Hi Alex,

I agree with Sloan's suggestion. VS IDE's html designer won't allow nested
quotes. Therefore as for databinding expression which will need multiple
quotes(nested), we use single quote to replace the outer pair.

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jun 14 '06 #3
Hey Alex,

Does that suggestion help you resolve the problem? If you still have any
question on this, please feel free to post here.

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jun 15 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Paul K | last post: by
1 post views Thread by Dot net work | last post: by
3 posts views Thread by Joel Daniels | last post: by
4 posts views Thread by Joel | last post: by
4 posts views Thread by Brad Baker | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.