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. get id/text of selected checkbox

get id/text of selected checkbox

Scheduled Pinned Locked Moved ASP.NET
helpquestiondatabase
11 Posts 3 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.
  • T terjk

    Based on the number of records i have in my DB, i wil generate a list of checkbox (but not checkbox LIST). So i traverse each row and i dim cbx as new checkbox after which i will have 3 -4 checkbox with the text in my web form. But the problem is... how can i get the id/text when the checkbox is being selected to carry out other function? I used checkbox (programmatically create) instead of checkbox list because i need to deal with tooltip which checkboxlist doesnt allow.. pls help...

    S Offline
    S Offline
    Sarvesvara BVKS Dasa
    wrote on last edited by
    #2

    If u dont use the checkbox list... u have to follow the same method u use to generate them... traverse thru the database... check if the current check box (i guess ID of the checkbox is same or related to the database data) is selected... perform the operation If u use the checkboxlist... use FindControl... ;) He who controls others may be powerful,
    But he who has mastered himself is mightier still.

    1 Reply Last reply
    0
    • T terjk

      Based on the number of records i have in my DB, i wil generate a list of checkbox (but not checkbox LIST). So i traverse each row and i dim cbx as new checkbox after which i will have 3 -4 checkbox with the text in my web form. But the problem is... how can i get the id/text when the checkbox is being selected to carry out other function? I used checkbox (programmatically create) instead of checkbox list because i need to deal with tooltip which checkboxlist doesnt allow.. pls help...

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #3

      Add ChechedChange event handler to each CheckBox. Then in that event you can get those information like this:

      CheckBox chb = (CheckBox)sender;
      string str = chb.Text;
      bool b = chb.Checked;
      string id = chb.ID;

      Mazy "I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein

      S T 2 Replies Last reply
      0
      • M Mazdak

        Add ChechedChange event handler to each CheckBox. Then in that event you can get those information like this:

        CheckBox chb = (CheckBox)sender;
        string str = chb.Text;
        bool b = chb.Checked;
        string id = chb.ID;

        Mazy "I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein

        S Offline
        S Offline
        Sarvesvara BVKS Dasa
        wrote on last edited by
        #4

        Good one :) Doesnt this take a round trip to the server and back to the client :confused: He who controls others may be powerful,
        But he who has mastered himself is mightier still.

        M 1 Reply Last reply
        0
        • S Sarvesvara BVKS Dasa

          Good one :) Doesnt this take a round trip to the server and back to the client :confused: He who controls others may be powerful,
          But he who has mastered himself is mightier still.

          M Offline
          M Offline
          Mazdak
          wrote on last edited by
          #5

          S P S wrote: Doesnt this take a round trip to the server and back to the client Nope, if there are not so much record back from database. Mazy "I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein

          S 1 Reply Last reply
          0
          • M Mazdak

            S P S wrote: Doesnt this take a round trip to the server and back to the client Nope, if there are not so much record back from database. Mazy "I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein

            S Offline
            S Offline
            Sarvesvara BVKS Dasa
            wrote on last edited by
            #6

            Whatever the data be there.. it should go to the server for processing, right?? He who controls others may be powerful,
            But he who has mastered himself is mightier still.

            M 1 Reply Last reply
            0
            • S Sarvesvara BVKS Dasa

              Whatever the data be there.. it should go to the server for processing, right?? He who controls others may be powerful,
              But he who has mastered himself is mightier still.

              M Offline
              M Offline
              Mazdak
              wrote on last edited by
              #7

              S P S wrote: Whatever the data be there.. it should go to the server for processing, right?? So what? Database is located on server , data should be read and return to clients. Does it relevant to question of original poster? He asked how to play with CheckBox programically, that all. Is that related to server and client processing ! Mazy "I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein

              1 Reply Last reply
              0
              • M Mazdak

                Add ChechedChange event handler to each CheckBox. Then in that event you can get those information like this:

                CheckBox chb = (CheckBox)sender;
                string str = chb.Text;
                bool b = chb.Checked;
                string id = chb.ID;

                Mazy "I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein

                T Offline
                T Offline
                terjk
                wrote on last edited by
                #8

                Add checkedchange event handler? How to? Sorry, i'm not that good in programming. So i need some time to digest everything. Dim cbx As New CheckBox AddHandler cbx.CheckedChanged, AddressOf CheckBox Must i have a subrountine to call the event? private sub checkedchange(byval sender as object.......)

                M 1 Reply Last reply
                0
                • T terjk

                  Add checkedchange event handler? How to? Sorry, i'm not that good in programming. So i need some time to digest everything. Dim cbx As New CheckBox AddHandler cbx.CheckedChanged, AddressOf CheckBox Must i have a subrountine to call the event? private sub checkedchange(byval sender as object.......)

                  M Offline
                  M Offline
                  Mazdak
                  wrote on last edited by
                  #9

                  Just like when you add pther handlers, C# syntax:

                  CheckBox1.CheckedChanged += new System.EventHandler(CheckBox1_CheckedChanged);

                  Mazy "I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein

                  T 1 Reply Last reply
                  0
                  • M Mazdak

                    Just like when you add pther handlers, C# syntax:

                    CheckBox1.CheckedChanged += new System.EventHandler(CheckBox1_CheckedChanged);

                    Mazy "I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein

                    T Offline
                    T Offline
                    terjk
                    wrote on last edited by
                    #10

                    .net syntax?

                    M 1 Reply Last reply
                    0
                    • T terjk

                      .net syntax?

                      M Offline
                      M Offline
                      Mazdak
                      wrote on last edited by
                      #11

                      helpNeeded wrote: .net syntax? :wtf: I don't know the VB.NET syntax , C# is a language which support .net framework. If you want to know how you do it in VB , just add a control in desgn time to your webform and then double click on it, so that VS.NET automaticlly add a event handler for you. Then go to your code behind and see how it add than handler. You do the same. Mazy "I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein

                      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