Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Checkboxfield in GridView

Checkboxfield in GridView

Scheduled Pinned Locked Moved ASP.NET
helpquestiondatabase
10 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Illegal Operation
    wrote on last edited by
    #1

    Hi! How can I create a ItemTemplate Checkbox that that gets the data from a database and display only the checkboxes and not the TRUE or FALSE text. The Code I currently have looks like this:

    If I change the "Text" to "Checked" I get a Cast error. Can anyone please help?

    Illegal Operation

    S A A A 4 Replies Last reply
    0
    • I Illegal Operation

      Hi! How can I create a ItemTemplate Checkbox that that gets the data from a database and display only the checkboxes and not the TRUE or FALSE text. The Code I currently have looks like this:

      If I change the "Text" to "Checked" I get a Cast error. Can anyone please help?

      Illegal Operation

      S Offline
      S Offline
      Suresh Suthar
      wrote on last edited by
      #2

      Use ctype function.

      Be an Eagle, Sky is Yours.

      I 1 Reply Last reply
      0
      • S Suresh Suthar

        Use ctype function.

        Be an Eagle, Sky is Yours.

        I Offline
        I Offline
        Illegal Operation
        wrote on last edited by
        #3

        and that would mean? I am using C#

        Illegal Operation

        1 Reply Last reply
        0
        • I Illegal Operation

          Hi! How can I create a ItemTemplate Checkbox that that gets the data from a database and display only the checkboxes and not the TRUE or FALSE text. The Code I currently have looks like this:

          If I change the "Text" to "Checked" I get a Cast error. Can anyone please help?

          Illegal Operation

          A Offline
          A Offline
          Abhijit Jana
          wrote on last edited by
          #4

          Illegal Operation wrote:

          Use Checked Property for that. Like :

          DBField should the field of your database.

          It will resolve your issue.

          Thanks !

          Abhijit Jana | Codeproject MVP
          Web Site : abhijitjana.net
          Don't forget to click "Good Answer" on the post(s) that helped you.

          A 1 Reply Last reply
          0
          • I Illegal Operation

            Hi! How can I create a ItemTemplate Checkbox that that gets the data from a database and display only the checkboxes and not the TRUE or FALSE text. The Code I currently have looks like this:

            If I change the "Text" to "Checked" I get a Cast error. Can anyone please help?

            Illegal Operation

            A Offline
            A Offline
            Anurag Gandhi
            wrote on last edited by
            #5

            Try this: <asp:CheckBox ID="chkLunch" runat="server" Checked='<%# Convert.ToBoolean(Eval("IsLunch")) %>' /> This should work provided IsLaunch should return value that is convertable to Boolean.

            Anurag Gandhi. http://www.gandhisoft.com Life is a computer program and every one is the programmer of his own life.

            I 1 Reply Last reply
            0
            • A Abhijit Jana

              Illegal Operation wrote:

              Use Checked Property for that. Like :

              DBField should the field of your database.

              It will resolve your issue.

              Thanks !

              Abhijit Jana | Codeproject MVP
              Web Site : abhijitjana.net
              Don't forget to click "Good Answer" on the post(s) that helped you.

              A Offline
              A Offline
              Anurag Gandhi
              wrote on last edited by
              #6

              Sorry, I didn't see your post before replying, so replied similar answer. :)

              Anurag Gandhi. http://www.gandhisoft.com Life is a computer program and every one is the programmer of his own life.

              A S 2 Replies Last reply
              0
              • A Anurag Gandhi

                Sorry, I didn't see your post before replying, so replied similar answer. :)

                Anurag Gandhi. http://www.gandhisoft.com Life is a computer program and every one is the programmer of his own life.

                A Offline
                A Offline
                Abhijit Jana
                wrote on last edited by
                #7

                :)

                Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

                1 Reply Last reply
                0
                • I Illegal Operation

                  Hi! How can I create a ItemTemplate Checkbox that that gets the data from a database and display only the checkboxes and not the TRUE or FALSE text. The Code I currently have looks like this:

                  If I change the "Text" to "Checked" I get a Cast error. Can anyone please help?

                  Illegal Operation

                  A Offline
                  A Offline
                  Abhishek Sur
                  wrote on last edited by
                  #8

                  Have you tried like this :

                  <asp:templatefield headertext="Author Name">
                  <itemtemplate>
                  <asp:Checkbox id="chkLunch" runat="server" Text= '<%# Eval("IsLunch") %>' />
                  </itemtemplate>

                  Means have you placed in the ItemTemplate of asp:templatefield ?

                  Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                  My Latest Articles-->** Simplify Code Using NDepend
                  Basics of Bing Search API using .NET
                  Microsoft Bing MAP using Javascript

                  1 Reply Last reply
                  0
                  • A Anurag Gandhi

                    Sorry, I didn't see your post before replying, so replied similar answer. :)

                    Anurag Gandhi. http://www.gandhisoft.com Life is a computer program and every one is the programmer of his own life.

                    S Offline
                    S Offline
                    sashidhar
                    wrote on last edited by
                    #9

                    :mad:

                    LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

                    1 Reply Last reply
                    0
                    • A Anurag Gandhi

                      Try this: <asp:CheckBox ID="chkLunch" runat="server" Checked='<%# Convert.ToBoolean(Eval("IsLunch")) %>' /> This should work provided IsLaunch should return value that is convertable to Boolean.

                      Anurag Gandhi. http://www.gandhisoft.com Life is a computer program and every one is the programmer of his own life.

                      I Offline
                      I Offline
                      Illegal Operation
                      wrote on last edited by
                      #10

                      Thank you very much!! Your answer solved my problem.

                      Illegal Operation

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups