How to conditionally check a radiobutton inside repeater

I have a repeater inside a AjaxToolKit tabpanel on a ascx page of a website. The repeater is databound in codebehind and in the ascx like so:

   <asp:TextBox ID="txtLastName" runat="server" Enabled="false" Font-Size="11px" Text='<%# Container.DataItem("Lastname")%>'  Width="80px" Font-Names="Arial"></asp:TextBox></td>

<td style="text-align: center">
  <asp:RadioButton ID="rdbAchieved" runat="server" />

I would like to check the radiobutton at runtime based on the value of another dataitem ("Achievement") in the datasource i.e. the radiobutton should be checked only if the  dataitem ("Achievement")  = 2

I know this can also be done in codebehind in the repeater's ItemDataBound event and I have done that with no problems but would like to know if the above is also possible?

Many thanks in advance.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

David Johnson, CD, MVPOwnerCommented:
if  ((Achievement  = 2) & (Radiobutton1.checked == $true)) {
// do something }
Al230762Author Commented:
Thank you David. Could you please clarify how your suggested script could be integrated into the properties of the radiobutton? I was thinking something like the following but it's not right:

<td style="text-align: center">
   <asp:RadioButton ID="rdbAchieved" runat="server" Checked='<%# Eval(Container.DataItem("Achievement")) == 2 ? True : False %>'/>
David Johnson, CD, MVPOwnerCommented:
my example was in the code behind.
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Al230762Author Commented:
I'm fine with the code behind and have achieved that successfully as I indicated in the original question but I want to do this client side for various reasons. Any ideas on how to achieve that?
Many thanks.
 <asp:RadioButton ID="rdbAchieved" runat="server" Checked='<%#Convert.ToInt32 (DataBinder.Eval(Container.DataItem,"Achievement")) == 2 ? True : False %>'/>

Open in new window

Al230762Author Commented:
Thanks dejaanbu - but that is exactly what I have already tried (see my 2nd post) and it does not work because of syntax errors.

But in my answer i added convert.int32 function for converting the value to an integer before comparison. just try that.
Al230762Author Commented:
Sorry dejaanbu. I should have been clearer. I did try your exact script but I still see the syntax errors on the double equals ("Expression expected") and also on False ("Syntax error"). Any idea why?
instead of True and False, put true and false (case-sensitive)
Al230762Author Commented:
Thanks dejaanbu but that makes no difference. In fact when I change True to true  the script auto-reverts to True as you can see below.

Also "==" has the error "expression expected"
"?" has the error "The ? character cannot be used here"
"false" has the error "Syntax error"

<asp:RadioButton ID="rdbAchieved" runat="server" Checked='<%#Convert.ToInt32(DataBinder.Eval(Container.DataItem, "Achievement")) == 2 ? True : false %>'/>

Seems like it should be such a simple thing but how can I get this correct?
r u using C# or VB ? i guessed that u r using C#.
try this VB version
<asp:RadioButton ID="rdbAchieved" runat="server" Checked='<%#If(Convert.ToInt32(DataBinder.Eval(Container.DataItem, "Achievement")) = 2, True, False) %>'/>

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
Al230762Author Commented:
Apologies for the delayed response. Many thanks dejaangu - that is the correct syntax. I am indeed using VB and again, sorry I didn't make that clear.
No problems... Glad to be of help! :)
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

From novice to tech pro — start learning today.