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. check box in the datagrid

check box in the datagrid

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netquestion
11 Posts 5 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.
  • R Offline
    R Offline
    rameshdontagani
    wrote on last edited by
    #1

    hi, i have a checkbocxcolumn in the datagrid.. i need to select only one checkbox..and if he selects more than one checkbox...it has to show a message that .."select only one checkbox" how can i do this in asp.net

    M J 2 Replies Last reply
    0
    • R rameshdontagani

      hi, i have a checkbocxcolumn in the datagrid.. i need to select only one checkbox..and if he selects more than one checkbox...it has to show a message that .."select only one checkbox" how can i do this in asp.net

      M Offline
      M Offline
      Michael Sync
      wrote on last edited by
      #2
      1. declare one variable in Javascript 2) set it as 0 by default. 3) write the javascript code - if chk is checked then if thisvariable less than 1 then set this variable to 1 else thisvariable is 1 then show the alert("select only one checkbox") else // chk is unchecked set thisvariable to 1 4) Add this code in onclick (client-side) event of checkedbox

      Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)

      1 Reply Last reply
      0
      • R rameshdontagani

        hi, i have a checkbocxcolumn in the datagrid.. i need to select only one checkbox..and if he selects more than one checkbox...it has to show a message that .."select only one checkbox" how can i do this in asp.net

        J Offline
        J Offline
        John ph
        wrote on last edited by
        #3

        beklo.com/rameshgoudd wrote:

        i have a checkbocxcolumn in the datagrid.. i need to select only one checkbox..and if he selects more than one checkbox...it has to show a message that .."select only one checkbox"

        Why don't you have a radio button in that column?

        - Regards -
           JON


        Life is not measured by the amount of breaths we take, but by the moments that take our breath away.


        S 1 Reply Last reply
        0
        • J John ph

          beklo.com/rameshgoudd wrote:

          i have a checkbocxcolumn in the datagrid.. i need to select only one checkbox..and if he selects more than one checkbox...it has to show a message that .."select only one checkbox"

          Why don't you have a radio button in that column?

          - Regards -
             JON


          Life is not measured by the amount of breaths we take, but by the moments that take our breath away.


          S Offline
          S Offline
          Sun Rays
          wrote on last edited by
          #4

          Hi, in the gridview even if you put radio button then it will not solve problem. Bcoz in grdview it will vreate dynamically radiobutton. And you cant get result as you can get in simple radiobutton.

          Thanks, Sun Rays To get something you must have to try once. My Articles

          N J 2 Replies Last reply
          0
          • S Sun Rays

            Hi, in the gridview even if you put radio button then it will not solve problem. Bcoz in grdview it will vreate dynamically radiobutton. And you cant get result as you can get in simple radiobutton.

            Thanks, Sun Rays To get something you must have to try once. My Articles

            N Offline
            N Offline
            N a v a n e e t h
            wrote on last edited by
            #5

            Sun Rays wrote:

            in the gridview even if you put radio button then it will not solve problem. Bcoz in grdview it will vreate dynamically radiobutton. And you cant get result as you can get in simple radiobutton.

            But with small programming trick, you can do it.

            All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

            1 Reply Last reply
            0
            • S Sun Rays

              Hi, in the gridview even if you put radio button then it will not solve problem. Bcoz in grdview it will vreate dynamically radiobutton. And you cant get result as you can get in simple radiobutton.

              Thanks, Sun Rays To get something you must have to try once. My Articles

              J Offline
              J Offline
              John ph
              wrote on last edited by
              #6

              Sun Rays wrote:

              in the gridview

              DataGrid

              Sun Rays wrote:

              if you put radio button then it will not solve problem

              Did I tell that it will solve the problem? Have you ever seen in any web page having a list of check boxes in the same group, when user selects more than one prompting a message saying "don't select more than one". Don't that sort of design defeats the purpose of using Check boxes?

              - Regards -
                 JON


              Life is not measured by the amount of breaths we take, but by the moments that take our breath away.


              S 1 Reply Last reply
              0
              • J John ph

                Sun Rays wrote:

                in the gridview

                DataGrid

                Sun Rays wrote:

                if you put radio button then it will not solve problem

                Did I tell that it will solve the problem? Have you ever seen in any web page having a list of check boxes in the same group, when user selects more than one prompting a message saying "don't select more than one". Don't that sort of design defeats the purpose of using Check boxes?

                - Regards -
                   JON


                Life is not measured by the amount of breaths we take, but by the moments that take our breath away.


                S Offline
                S Offline
                Sun Rays
                wrote on last edited by
                #7

                Hi Guys, As I were said, in datagrid / gridview if putting radio button then that will be in templatefield. and if you know then its creating radiobutton at runtime for every row. So cant assign group in that radio button. So will you be with your radio button everytime ? :laugh: :laugh: :laugh: What now ? any doubt ?

                Thanks, Sun Rays To get something you must have to try once. My Articles

                J 1 Reply Last reply
                0
                • S Sun Rays

                  Hi Guys, As I were said, in datagrid / gridview if putting radio button then that will be in templatefield. and if you know then its creating radiobutton at runtime for every row. So cant assign group in that radio button. So will you be with your radio button everytime ? :laugh: :laugh: :laugh: What now ? any doubt ?

                  Thanks, Sun Rays To get something you must have to try once. My Articles

                  J Offline
                  J Offline
                  John ph
                  wrote on last edited by
                  #8

                  I can understand that Using radio-button in a DataGrid will have the same effect as CheckBox. Will that be a problem if we write a JavaScript function to control the single selection of the radio-button list. There's another alternative too to sort this problem, by Adding a label and dynamically adding HTML input tag as Label Text with type as radio and runat server enabled and with the same group name. This works.

                  Sun Rays wrote:

                  So cant assign group in that radio button.

                  Try dynamically adding HTML Server Input Control with type radio and with the same group name.

                  Sun Rays wrote:

                  So will you be with your radio button everytime ?

                  Yes, when required.

                  - Regards -
                     JON


                  Life is not measured by the amount of breaths we take, but by the moments that take our breath away.


                  S 1 Reply Last reply
                  0
                  • J John ph

                    I can understand that Using radio-button in a DataGrid will have the same effect as CheckBox. Will that be a problem if we write a JavaScript function to control the single selection of the radio-button list. There's another alternative too to sort this problem, by Adding a label and dynamically adding HTML input tag as Label Text with type as radio and runat server enabled and with the same group name. This works.

                    Sun Rays wrote:

                    So cant assign group in that radio button.

                    Try dynamically adding HTML Server Input Control with type radio and with the same group name.

                    Sun Rays wrote:

                    So will you be with your radio button everytime ?

                    Yes, when required.

                    - Regards -
                       JON


                    Life is not measured by the amount of breaths we take, but by the moments that take our breath away.


                    S Offline
                    S Offline
                    Sun Rays
                    wrote on last edited by
                    #9

                    Hi,

                    John Prabhu wrote:

                    Try dynamically adding HTML Server Input Control with type radio and with the same group name.

                    Have you tried for this ? Hope is works fine.... :)

                    Thanks, Sun Rays To get something you must have to try once. My Articles

                    J 1 Reply Last reply
                    0
                    • S Sun Rays

                      Hi,

                      John Prabhu wrote:

                      Try dynamically adding HTML Server Input Control with type radio and with the same group name.

                      Have you tried for this ? Hope is works fine.... :)

                      Thanks, Sun Rays To get something you must have to try once. My Articles

                      J Offline
                      J Offline
                      John ph
                      wrote on last edited by
                      #10

                      Sun Rays wrote:

                      Have you tried for this ?

                      Yes, Radio-Button Column on a DataGrid is the first Design-Template which I coded few years ago...

                      - Regards -
                         JON


                      Life is not measured by the amount of breaths we take, but by the moments that take our breath away.


                      S 1 Reply Last reply
                      0
                      • J John ph

                        Sun Rays wrote:

                        Have you tried for this ?

                        Yes, Radio-Button Column on a DataGrid is the first Design-Template which I coded few years ago...

                        - Regards -
                           JON


                        Life is not measured by the amount of breaths we take, but by the moments that take our breath away.


                        S Offline
                        S Offline
                        Sun Rays
                        wrote on last edited by
                        #11

                        Hello, I have tried all in V 2 but I didnt find ever that works like group...

                        Thanks, Sun Rays To get something you must have to try once. My Articles

                        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