asp linkbutton commandargument value results in "The server tag is not well formed"

I have a repeater control which populates a table with asp:linkbuttons.

The asp:linkbuttons each have a different commandName, obviously, but their commandarguments will all be the same. I want their commandarguments to be populated by a data item from the repeater control called "SERVICE_ID".

The following code causes an error when compiled: "The server tag is not well formed"
<td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3"><asp:LinkButton runat="Server" id="linkButton1" CssClass="lnkbutton" CommandName="Collection_All" CommandArgument="<%# eval("Service_ID") %>"><%#databinder.eval(container.dataitem,"Collection_Count") %></asp:LinkButton></td>

However, when I replace the commandargument with just a plain old string hard-coded in like "1234", it compiles without a problem.

So what is wrong with the syntax CommandArgument="<%# Eval("Service_ID") %>" ???

Thank you,
Who is Participating?
Swapnil PipariaConnect With a Mentor ArchitectCommented:
Hi rss2,
  try changing

CommandArgument="<%# Eval("Service_ID") %>"


CommandArgument= '<%# Databinder.Eval(container.dataitem,"Service_ID") %>'

because service_id is databound item.


<%# databinder.eval(container.dataitem, "Service_ID") %>

fix it?
rss2Author Commented:
I tried both syntax methods but neither worked.

HOWEVER, it was surrounding it with double quotes which made it fail!

THANK YOU!!! I have used your commandargument above with single quotes as you have and it's working. :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.