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. Getting the Checked items of a datagrid in an Array.

Getting the Checked items of a datagrid in an Array.

Scheduled Pinned Locked Moved ASP.NET
tutorialdata-structureshelpquestion
5 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.
  • S Offline
    S Offline
    SrividhyaS
    wrote on last edited by
    #1

    Hi there, I have a doubt reg the Datagrid which uses a CheckBox Column. I have a Webform.In that I have 2 option buttons,1 Datagrid,1 Button. The 2 option buttons are : 1)Employee_btn(When i select this,Datagrid will be filled with the Employee ID,Employee name along with the CheckBox Column). 2)Department_btn(When i select this,Datagrid will be filled with the Department_name) 1 Button is Submit_Btn Now my requirement is I need to take the checked Items from the datagrid and store it in a char Array(For example,when I select 2 out of 3 department names I need to store the two department names in a string array. How to do that?? Kindly help me as soon as possible.I need to finish this with in 3 days. Thanks in advance.

    Happy Programming!!!

    M B 2 Replies Last reply
    0
    • S SrividhyaS

      Hi there, I have a doubt reg the Datagrid which uses a CheckBox Column. I have a Webform.In that I have 2 option buttons,1 Datagrid,1 Button. The 2 option buttons are : 1)Employee_btn(When i select this,Datagrid will be filled with the Employee ID,Employee name along with the CheckBox Column). 2)Department_btn(When i select this,Datagrid will be filled with the Department_name) 1 Button is Submit_Btn Now my requirement is I need to take the checked Items from the datagrid and store it in a char Array(For example,when I select 2 out of 3 department names I need to store the two department names in a string array. How to do that?? Kindly help me as soon as possible.I need to finish this with in 3 days. Thanks in advance.

      Happy Programming!!!

      M Offline
      M Offline
      Member 3879881
      wrote on last edited by
      #2

      Means selected departments want to be store in table fields?,

      Regards, Magi

      S 1 Reply Last reply
      0
      • M Member 3879881

        Means selected departments want to be store in table fields?,

        Regards, Magi

        S Offline
        S Offline
        SrividhyaS
        wrote on last edited by
        #3

        Table field is also ok.... FYI i am using asp.net with C#..

        Happy Programming!!!

        M 1 Reply Last reply
        0
        • S SrividhyaS

          Table field is also ok.... FYI i am using asp.net with C#..

          Happy Programming!!!

          M Offline
          M Offline
          Member 3879881
          wrote on last edited by
          #4

          Hi i am given code based on vb.net..., c# and vb.net both are similar only..., I hope,my code will be use full for u..., For Each MainGRD As DataGridItem In Me.dgrdmain.Items 'dgrdmain is datagrid id name sqlconn.Open() Dim Check As CheckBox = CType(MainGRD.FindControl("ck"), CheckBox) 'ck is checkbox id name If Check.Checked = True Then Dim strInsertproc As String Dim EId As Integer = Val(MainGRD.Cells(1).Text) Dim BcCal As Decimal = Val(MainGRD.Cells(2).Text) 'like the above code u can get the values from datagrid cells..., Try strInsertproc = "spn'" & EId & "','" & BcCal & "'" 'spn is stored procedure name sqlCmd = New SqlCommand(strInsertproc, sqlconn) sqlCmd.ExecuteNonQuery() lblMessage.Text = "Record Inserted............" Catch ex As Exception If Mid(ex.Message, 1, 9) = "Violation" Then lblMessage.Text = "Already exist in the DataBase......" Else lblMessage.Text = Mid(ex.Message, 1, 75) ' Show friendly error message. End If End Try End If sqlconn.Close() Next Take care...,

          Regards, Magi

          1 Reply Last reply
          0
          • S SrividhyaS

            Hi there, I have a doubt reg the Datagrid which uses a CheckBox Column. I have a Webform.In that I have 2 option buttons,1 Datagrid,1 Button. The 2 option buttons are : 1)Employee_btn(When i select this,Datagrid will be filled with the Employee ID,Employee name along with the CheckBox Column). 2)Department_btn(When i select this,Datagrid will be filled with the Department_name) 1 Button is Submit_Btn Now my requirement is I need to take the checked Items from the datagrid and store it in a char Array(For example,when I select 2 out of 3 department names I need to store the two department names in a string array. How to do that?? Kindly help me as soon as possible.I need to finish this with in 3 days. Thanks in advance.

            Happy Programming!!!

            B Offline
            B Offline
            Blumen
            wrote on last edited by
            #5

            Hi, Your issue is addressed in this Code Project article: http://www.codeproject.com/aspnet/datagrid_checkbox.asp[^] I hope this would help you with your homework! Regards, Blumen

            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