Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8043789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:01:17+00:00 2026-06-05T05:01:17+00:00

I have a button and a checkbox in a template field in an asp

  • 0

I have a button and a checkbox in a template field in an asp GridView. I want the disabled property of the button and the checked property of the checkbox to be set conditionally based on the Data Field Expiration. If Expiration equals Permanent, then the button should be disabled and the checkbox checked. If not, then the button is enabled and checkbox unchecked. I’ve tried:

<input type="button" id="expiration" disabled='<%# (string)Eval("Expiration") == "Permanant" ? "disabled" : "enabled" %>' value='<%# Eval("Expiration") %>'/>
<input type="checkbox" id="permanent" checked= '<%# (string)Eval("Expiration") == "Permanant" ? "checked" : "unchecked" %>'/>

But it seems that just having the disabled and checked attributes listed at all is causing all buttons to be disabled and all checkboxes checked.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:01:18+00:00Added an answer on June 5, 2026 at 5:01 am

    disabled and checked are boolean attributes. They accept only the values disabled and checked respectively.

    If you don’t want the control to be checked/disabled by default then do not include the attribute at all.

    Since they are boolean attributes, you may omit everything except the value.

    <input type="button" 
           id="expiration" 
           <%# (string)Eval("Expiration") == "Permanant" ? "disabled" : "" %> 
           value='<%# Eval("Expiration") %>'>
    <input type="checkbox" 
           id="permanent" 
           <%# (string)Eval("Expiration") == "Permanant" ? "checked" : "" %>>
    

    Your checkbox should have an explicit value though, see the comment in the DTD:

      value       CDATA          #IMPLIED  -- Specify for radio buttons and checkboxes --
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a checkbox in a template field of a gridview and i want
I have a Checkbox template column in a ASP.NET 3.5 GridView. Now the user
I have a gridview that has a template field containing a checkbox as one
I have a checkbox template field within a gridview in c#, this field also
I have a user control that contains multiple controls (CheckBox, Button, Label...). I want
I have a gridview with checkbox inside asp:TemplateField . I wish to select multiple
I have added a button to a template for a ListBoxItem. I want to
I have a gridview with a template field. In that template field is a
I have a gridview where one column is an Add / Remove asp:button which
I have a checkbox with id terms and a submit button in my form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.