Label Click in Repeater with Datacolumn

I have a label in a repeater. The label has an onclick event, which requires it use an apostrophe rather than a double quote. But I also use a datacolumn in the onclick event as a parameter and it requires a single quote.

I've tried escaping the single quote inside the onclick event. No.
I've tried leaving out the quote when I pass the parameter. No.

Here is what I have:

<asp:Label ID="btnViewMore"
Text='<%# Eval("dcViewMore").ToString()%>' CssClass="stylViewMoreBtn"
OnClick='loadOverview("<%# Eval("dcEmployeeId").ToString()%>;return false;")' runat="server"></asp:Label>

Open in new window


How do folks use a datacolumn in an onclick event where a single quote is required? thanks!
LVL 2
Starr DuskkASP.NET VB.NET DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
If I use two apostrophes:
The server tag is not well formed.
If I use a double quote with an apostrophe.
The server tag is not well formed.

If I use this:

OnClick='loadOverview("<%# Eval("dcEmployeeId").ToString()%>")'

Open in new window


viewing source looks like this:

OnClick="loadOverview(&quot;&lt;%# Eval(&quot;dcEmployeeId&quot;).ToString()%>&quot;)"

Open in new window

Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
I figured out:

in front:

                                <asp:Label ID="btnViewMore"
                                    Text='<%# Eval("dcViewMore").ToString()%>' CssClass="stylViewMoreBtn"
                                     runat="server"></asp:Label>
                                  <asp:HiddenField ID="hdnEmployeeId" Value='<%# Eval("dcEmployeeId").ToString()%>' runat="server" />

Open in new window


behind:

I have an ItemDataBound...

    Private Sub repRepeater_ItemDataBound(sender As Object, e As RepeaterItemEventArgs) Handles repRepeater.ItemDataBound

(...snip)...

             Dim hdnEmployeeId As New HiddenField
                hdnEmployeeId = CType(e.Item.FindControl("hdnEmployeeId"), HiddenField)

                Dim btnViewMore As New Label
                btnViewMore = CType(e.Item.FindControl("btnViewMore"), Label)
                Dim cmdArgument As String = hdnEmployeeId.Value

                btnViewMore.Attributes.Add("onClick", String.Format("loadOverview('{0}')", cmdArgument))

    End Sub

Open in new window

Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
see above.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.